How to use custom build agent in Azure DevOps - azure-devops

I have created a custom build agent in Azure DevOps. I can view the agent in agent pool, but there is no option to select the agent when queuing the build.
I want to run the build using that custom build agent. So please guide me on how to configure the build pipeline to run with custom build agent.

When you create a self-hosted (I assume you mean this by custom, right?) agent it goes to the Default pool.
So you need to select this pool when you run a build. You can either set this pool as a default for the build in the build configuration OR you can select it right before you start the build instead of the default one.

Related

Extend template validation at build queue time

I know that we can verify extend template used or not at deployment stage on targeted azure devops environment using extend template check.
I have a requirement to verify or run this check at run time before any of the build task starts i.e. when user run the build . I've asked similar question here Azure pipeline build Stage verification but as a centralized compliance team we want to block user from running the build if they are not extending certain template.
You can achieve above requirement by setting a template check for the agent pools. If a agent pool is configured approvals and checks, then all the jobs that targeting this agent pools will need to validate the approvals and checks before running.
You can follow below steps to set approvals and checks for agent pools.
Go to Project settings --> Agent pools under Pipelines-->Select the agent pools(eg. Azure Pipelines).
Click the 3dots on the top right corner--> Click Approvals and checks--> Click the plus sign to Add a template check.
Then all the jobs that targeting an agent in this agent pool will have to pass the template checks before running on the agent.
Note: Please make sure the Multi-stage pipelines experience is turned on. Check the document here here to turn on or off the Preview features.

Run azure devops pipeline on every available pool

I'm evaluating Azure Devops and want to have following workflow: I want to have a pipeline build and run it on our self-hosted build agent, but if non them is available I want to fall back on hosted agent and vice versa. According to documentation https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops in the yaml file you need to define in which pool will job run.
Can I have a pipeline build without having to define a pool/define many pools as fallback?

deploy app to on-prem environments with azure dev ops

I'm building an Azure DevOps pipeline to deploy a custom-build powershell application to several on-prem environments that we support. I configured the required agent pools and installed them as a service on the on-prem environment.
Next, I have set up my pipeline in Azure DevOps, selecting a GitRepo:
Build (with the steps: Use Nuget, Nuget Restore, Build solution, Update version, Copy Files, and Publish build Artifact)
Release (with step: Publish Build Artifact)
Some things are unclear for me:
Do I need the Publish Build Artifacts twice? Can the Build pipeline
end with Copy Files step, and that the Release pipeline picks up this
artifact?
It is my understanding that the release publishes the app to the
on-prem environment (in my case). Where can I set a custom path (ie:
C:\deployed_apps) where the app needs to be deployed? When I tested
this pipeline, I got errors that the path I created using an variable
was not found.
What am I missing in my setup to get this pipeline working?
As #Shayki Abramczyk
pointed out this task is not for deployment, it just upload your Build Artifacts to azure devops server where your release pipeline can download directly.
In your case, if you want deploy your application to several on-prem environments, You need to create a deployment group first, A deployment group is a logical set of deployment target machines that have agents installed on each one. You application will be deployed to those machines in a deployment group in release pipeline. Check here for more details about deployment group.
After the deployment group is created, you can add a deployment group job by click the 3 dots, and then specify your deployment group as below pic shows, You can then simply add a copy file task or other deployment tasks to deploy your application to your on-prem machine.
In the release pipeline you shouldn't use the Publish Build Artifact. in the end of the build you put this step, what this step does? upload your artifacts to the Azure DevOps or to a file share. now in the release pipeline you choose the build artifact (in the left pane). the first thing that the agent does when the release pipeline started is to download the build artifacts to the agent. now you need to take them and deploy it to your environments. how? it depends which kind of application is (it can be just copy files, it can be deploy to IIS, etc.).
You can put the path in the variables tab and use this variable when you deploy the app (with copy files task, for example).

VSTS Build and Release definition: Could both build and release definition use the same agent or each must use different agent?

I'm currently creating a release definition for our project and I'm stuck with this problem, could both build and release definition use the same agent if yes, then how? If no, what are other options to do this?
I've already posted the same question on github and Microsoft developer community. Here are the links:
Microsoft Dev:
https://developercommunity.visualstudio.com/content/problem/108045/could-both-build-and-release-definition-use-the-sa.html#
Github:
https://github.com/Microsoft/vsts-agent/issues/1193
Yes.
Set agent for release:
Set default agent for build (You can change agent when queue build)
An article about setup a private agent: Deploy an agent on Windows
Yes, both your build and release definitions can use the same set of agents ( which are called Agent Queues in VSTS )
For eg. - You can configure an agent in the "Default" agent queue in VSTS and configure both your build and release definitions to use "Default" queue. This will allow you to run both builds and releases but a single agent can only run any one of them at one point of time
https://www.visualstudio.com/en-us/docs/build/concepts/agents/pools-queues

Does VSO support local build agent?

The new TFS Build does not seem to have an option to target the Build to a local build controller, is this correct?
I can only see "Hosted" or "Default" in the General tab.
https://msdn.microsoft.com/en-us/Library/vs/alm/Build/overview
Create a new pool
Create a new queue
Download and configure the agent
More details can be found on Deploy an agent to build Windows and Azure apps