is it possible to change the agent.name? without to delete the agent and reinstall?
linux system
picture
I try to vim the config.sh and I didn't find that variable
I am afraid that there is no such method can directly change the agent name without re-installing the self-hosted agent.
The agent name is a primary key in the backend. We need to re-install the self-hosted agent, then you can change the self-hosted agent name.
Refer to the doc about the steps to re-install the self-hosted agent.
I can fully understand your requirement. You can create a suggestion ticket in Developer Community to report your requirement.
Related
To know if you are on CI of working locally you can use TF_BUILD, but I could not see any environment variable that helps me discern between a self-hosted and a microsoft-hosted agent.
How can you do that, without having to manually define a custom environemnt variable in our self-hosted machines?
Update: why do I need this? There are things that work in one way or another depending if it is ms-hosted or self-hosted. e.g. python virtual environements see microsoft/azure-pipelines-tasks Issue 15417.
How about using Agent.Name? It is a predefined variable, which has:
The name of the agent that is registered with the pool.
If you are using a self-hosted agent, then this name is specified by you. See agents.
Assuming your naming scheme allows you to tell the difference between your own agents and MS hosted agents, that should do the job?
I have configured self-hosted agents behind a pool that has enabled "Allow agents in this pool to automatically update" option. When there are a new version, I can see that the update proccess try to upgrade agents, but nothing happens. I can´t see any error. What I can see is that new agent version is downloading, then the agent turn off-line, then on-line but the agent version is the same old version.
I can download manualy the new agent version from the build server, so I dont know what's wrong.
Please, does anyone knows what i have to do in order to get agents automatically updated.
No matter what, you should update the agent manually every time to enable the new feature of it. And there is no such option for azure devops to update the private agent automatically when you make changes.
You could configure your private agent to run as a windows service, but that is for restarting agent. I think that is not what you want. When you make changes for agent(not restart), you have to update the agent manually.
As a suggestion, you should suggest a feature to the Team and then they will give you any feedback about the new idea.
In order to update Self-hosted agent automatically It's required to configure URLs and IPs in Firewall/Proxy settings. Please go to:
https://learn.microsoft.com/en-us/azure/devops/organizations/security/allow-list-ip-url?view=azure-devops&tabs=IP-V4#ip-addresses-and-range-restrictions
We use Azure DevOps Server 2020 on prem. We are not in a position to move to Services. We are not in a position to use agents in Azure, because these agent would not be able to talk to the server, which is behind the corporate firewall.
So, we are stuck with on-prem agents and this suffocates us. Our app is a monolith in the worst sense of the word. Its PR build takes time and is extremely hungry on resources. Currently we have 2-3 PR builds running concurrently on the same machine and it takes eternity. In short - it is very bad.
On the other hands, developers have pretty powerful machines. Of course, I do not want my machine to serve PR builds of others, but if it could run my own PR build, that would be fantastic.
Alas, I do not see how this can be done. So, my question - is it possible to configure Azure DevOps Server 2020 so that PR validation build for a PR submitted by Alice would run on the build agent running on Alice's machine and only if there is no such agent would it pick up a "standard" build agent running on a build server?
Clarification
Although the question speaks about Alice, but there are also Bob and Charlie and Deepak. About 300+ developers. So, the solution should not assume there is only one developer working on the code.
is it possible to configure Azure DevOps Server 2020 so that PR validation build for a PR submitted by Alice would run on the build agent running on Alice's machine
We could install the self-hosted agent in the Alice's machine, open Organization Settings->Agent pools->select the agent->click the tab Capabilities->search the field Agent.ComputerName, then open PR build definition and add Demands, such as below.
Then the PR build will run with the specified agent, you could check this doc: Specify demands
for more details.
In addition, if the PR build does not find the matching agent, the build will not run with another agent.
Update1
Each developers have their owner agent on their owner’s machine, right?
Check this doc: predefined variables, it contain the variable Build.RequestedFor and Build.RequestedForEmail, if the pipeline is pull request trigger, it will show the pull request creator name and email, add this to the pipeline Demands. Such as
And then, let all developers add capabilities to their agents, such as TriggerName = {their email or display name}. Since I am using the variable Build.RequestedForEmail, in my agent, I add the capabilities:
Then if I create a pull request, the build will run via my own machine agent.
Update 2
For example, the original PR build name is A. Open it and add default demand(you could add anything)
Add new build definition name B, add task power shell and enter power shell script to call below REST API to update the A definition
Definitions - Get
GET https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=6.1-preview.7
Definitions - Update
PUT https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=6.1-preview.7
Then add build B as pull request build.
Update3
is it possible to configure Azure DevOps Server 2020 so that PR validation build for a PR submitted by Alice would run on the build agent running on Alice's machine and only if there is no such agent would it pick up a "standard" build agent running on a build server?
If the "real" targets the build agent initially, then what happens when the auxiliary one determines the dev has an individual agent?
The real build definition has demands, If the build runs by default demands, it will run the standard build agent.
The auxiliary one, we need to add condition to run the power shell script to update the real build demands. if Alice's machine has matching agent, it will update the real build demands, and then the real build will run the Alice's machine agent.
Is it possible to clone or copy an Azure Pipeline Hosted Agent for use as a Self-Hosted Agent?
I'd like to reuse one of the Hosted Agents simply to enable me recreate and reuse all of its
capabilities, saving me the headache. Is this possible and if so I'd really appreciate some help.
Thanks
This is not possible, but you can try to reuse what is already available here https://github.com/actions/virtual-environments
This repository contains the source used to create the virtual environments for GitHub Actions hosted runners, as well as the VM images of Microsoft-hosted agents used for Azure Pipelines. To file bug reports, or request that tools be added/updated, please open an issue using the appropriate template. To build a VM machine from this repo's source, see the instructions.
So you can use the same scripts which are used to create Microsoft Hosted agents.
There is no such build-in feature.
Azure DevOps provides free hosted agents that have a predefined set
of tools installed and configured for building and releasing your
apps.
There is another option where you set up and manage your own agents.
This can be done by simply downloading the agent package, and run it
either on your local machine or any other computing platform even on
Docker container. It also gives you more freedom to install specific
dependencies for your build and release.
If you want to build your own agent during the pipeline. I would suggest you use Docker container to handle the process.
Microsoft has already created pre-configured container images on Docker Hub for everybody to use. But they’re Linux based and don’t contain any additional applications and/or packages so you’d probably still need to add those every time you run your build.
This repository contains images for the Visual Studio Team Services
(VSTS) agent that runs tasks as part of a build or release.
VSTS agent images are tagged according to the base OS, an optional
Team Foundation Server (TFS) version, and tools that are installed.
When used with VSTS, the agent version is automatically determined and
downloaded at container startup based on the account to which the
agent is connecting.
More detail step, you could refer this article: Build your own Azure DevOps agents with pipelines
We recently switched our Azure DevOps organization from the free Hosted Agent offering to two paid hosted agents. When the second hosted agent was added, it was automatically named "Azure Pipelines 2" which is a fine enough name. The issue is that the original agent seems to be named "Hosted Agent" and I can't for the life of me find a way to rename it. It would be great if it could just be renamed to "Azure Pipelines 1". Is it possible to rename a hosted agent? If so, how does one do this as I have looked in Organization Settings at the Agent Pools option and do not see any way to do this.
Rename Azure DevOps hosted Agent
For this issue , I am afraid this is currently not supported in Azure Devops. Hosted agent name cannot be modified.
Currently only private agent name can be renamed, run config.cmd remove first, that will take care of remove the windows service and also remove the agent from your azure devops , then run config.cmd again to re-config in order to change the agent name, the agent name is a primary key in the backend.
So I post a feature request here in DC forum for you . You could vote that suggestion ticket and share your comment there.The product team would provide the updates if they view it. Anyone interested in this can vote for it and track it.