2

What is the way to get a list of server names that were deployed to so they can be used in another job with a different agent in the same deployment pipeline?

We have a number of servers in a deployment group that get deployed to. We would like to point an automated test server to each of these environments to confirm the deployment went correctly. Therefor we need a list of the servers that were deployed.

Since the list of servers could grow or shrink we can't hard code all the servers to a variable.

As a workaround we created a Powershell step to call the REST API to get the deployment group machine details. However, we would like to achieve this using variables / outputs etc in the Azure Devops interface.

Morgan
  • 55
  • 9
  • The targets in deployment groups take tags in there. You can specify which target you want to deploy by tags. Haven't done it myself, though, but I was thinking can't you just test a server by tags, too? – Jabberwocky Feb 08 '19 at 18:19
  • How does one get a list of servers by tag? – Morgan Feb 12 '19 at 15:42
  • Is this what you need?: https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/targets/list?view=azure-devops-rest-5.0 .It says: tags 'query string array (string) Get only the deployment targets that contain all these comma separted list of tags.' Haven't tried it myself but you should be able to get the targets with a specific tag on them. It looks like it. – Jabberwocky Feb 13 '19 at 10:10
  • I believe you are suggesting the workaround we are trying to replace. – Morgan Feb 19 '19 at 21:15
  • you're not mentioning tags anywhere but maybe I've misunderstood. – Jabberwocky Feb 20 '19 at 10:41

2 Answers2

1

From what I can see, there is no easy way to get at what you want. As per designer documentation:

"When you specify multiple jobs in a build pipeline, they run in parallel by default. You can specify the order in which jobs must execute by configuring dependencies between jobs. Job dependencies are not yet supported in release pipelines. Multiple jobs in a release pipeline run in sequence."

I would imagine this is due to the added complexity inherent in allowing jobs to be run on x number of machines.

The yaml documentation doesn't seem to make the same distinction, but I think it is still a not yet feature, as yaml release pipelines as a whole seem to be a roadmap item.

Josh Gust
  • 4,102
  • 25
  • 41
1

One thing to be aware of is that variables you might set by command do not persist between phases. If you want to know the deployment servers that were deployed during a phase, you will need to find those during the test agent phase you are executing.

I think you answered your own question though. I believe most of the answers you get will be to use the API to get the information that you are desiring. That being said, the only real sure-fire was I think would be for you to add a step to the deployment group phase and let it run the tests on the deployment server.

Not the cleanest solution, but you could also have the deployment group trigger a build definition passing the server name. The build task would just have the testing portion that you want to run. You could have that release step depend on the completion/status of the build definition.

Some features to keep in mind when implementing whatever you decide:

Automatically deploy to new targets in a deployment group

Deploy to failed targets in a Deployment Group

Matt
  • 3,658
  • 3
  • 14
  • 27
  • Lets say we stick with the REST call solution as you suggest. Temporarily we hard coded the deployment group id in the rest call to get the environment details we needed for our test. If we stick with the REST call how can we get the deployment group id or target details from the release definition? We can't find the deployment group name or id anywhere in the results of GET RELEASE – Morgan Feb 11 '19 at 18:57