0

I created a classic release pipeline in Azure DevOps that looks like the following (this was just to test and verify I could re-create an issue I was having with another pipeline):

Release Pipeline

Each of the deployment group jobs is configured to "Run this job" "Only when all previous jobs have succeeded". It works great unless one of the PowerShell scripts fails and I want to redeploy. For example, lets say the PowerShell Script task for "Start Maintenance Mode" fails and I redeploy and choose the option to only "Redeploy to All jobs and deployment group targets that are either in failed, cancelled or skipped state". If I do that, it skips the PowerShell Task in "Do Something, Anything" (as expected), it then runs the failed PowerShell task for "Start Maintenance Mode" (as expected, and succeeds this time), but then it skips the PowerShell Task for "Stop Maintenance Mode" (not expected, since it was skipped last time and should be run during the redeploy). It shows "The job was skipped due to an unsatisfied condition.", and no further detail beyond that:

Missed Skipped Task

I've played around with custom conditions using variable expressions to try to get it to work, but I've had no luck. What am I missing/not understanding? What needs to be done to get it to redeploy and work correctly so that it actually runs all of the tasks that were skipped previously?

Jason
  • 1,238
  • 1
  • 15
  • 18

1 Answers1

0

I can see this issue, it is because that the "Do Something, Anything" job has been skipped and then condition for the "Stop Maintenance Mode" job is not met.

As a workaround you could follow below steps.

  1. Set a pipeline variable runYes to false
  2. Add a PowerShell task as the last step for "Start Maintenance Mode" job and set it "Only when all previous tasks have succeeded".
  3. The PowerShell task will run Rest API: Definitions - Update to update pipeline variable runYes to true.
  4. Set custom conditions for "Stop Maintenance Mode" job using variable expressions eq($(runYes), 'true')

Therefore, the "Stop Maintenance Mode" job will be run only the "Start Maintenance Mode" job is success. Another easier way is you choose to redeploy to "All jobs and all deployment group targets", thus all deployment jobs will run.

Edward Han-MSFT
  • 2,879
  • 1
  • 4
  • 9
  • Thanks for the suggestion. Is there a way to set the custom condition to something like 'not(failed())' or something that includes the skipped state? I've played around with that, but haven't been able to get anything that works. I'd rather not have to deal with custom variables and try to see if there's an expression that works for the custom condition...if that's possible. Thanks! – Jason Apr 14 '21 at 15:52
  • If you use yaml pipeline, you could use ```dependsOn``` syntax by reference to this doc: [Deployment jobs](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/deployment-jobs?view=azure-devops), so can decide the next job depends on the result of the former deployment job. However, this feature is not available in release pipeline. If you don't want to deal with custom variables, you could choose to redeploy to "All jobs and all deployment group targets", thus all deployment jobs will run, which is the easier workaround. – Edward Han-MSFT Apr 15 '21 at 02:54
  • Hmmm...back to the drawing board I guess. The statement "Redeploy to All jobs and deployment group targets that are either in failed, cancelled or skipped state" is false and misleading because it doesn't do what it says. Thanks for the suggestions though! – Jason Apr 15 '21 at 16:12
  • Feel free to contact us if you have other issues. – Edward Han-MSFT Apr 19 '21 at 06:09
  • Hi Jason, it seems the only way. You could [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235), it could help other community members who get the same issues and we could archive this thread, thanks. – Edward Han-MSFT May 04 '21 at 06:18
  • I'll accept this as the answer, since it does give suggestions on how to work around what should work but doesn't. ;-) – Jason May 06 '21 at 20:20