How can I conditionally trigger an Azure pipeline based on the results of another Azure pipeline?
I've got two Azure pipelines, P0 and P1. Currently, P1 is triggered to run when P0 completes as a build completion trigger.

If P0 fails, I do not want to trigger P1. There doesn't appear to be a way to add a condition to only trigger builds based on the successful completion of a previous build. We have to start P1 and cancel it based on a condition.
The only way I see to do this is via either:
- Setting an environment variable via a build script in P0,
Write-Host ("##vso[task.setvariable variable=BuildContinue;]$buildContinue"), and reading that variable via a script in P1 via a build task variable$(BuildContinue). - Setting a semaphore file as a build artifact in P0 and then downloading and reading that file in P1.
Both options require running the build. Is there a better way to conditionally run an Azure pipeline?
add a comment |
I've got two Azure pipelines, P0 and P1. Currently, P1 is triggered to run when P0 completes as a build completion trigger.

If P0 fails, I do not want to trigger P1. There doesn't appear to be a way to add a condition to only trigger builds based on the successful completion of a previous build. We have to start P1 and cancel it based on a condition.
The only way I see to do this is via either:
- Setting an environment variable via a build script in P0,
Write-Host ("##vso[task.setvariable variable=BuildContinue;]$buildContinue"), and reading that variable via a script in P1 via a build task variable$(BuildContinue). - Setting a semaphore file as a build artifact in P0 and then downloading and reading that file in P1.
Both options require running the build. Is there a better way to conditionally run an Azure pipeline?
add a comment |
I've got two Azure pipelines, P0 and P1. Currently, P1 is triggered to run when P0 completes as a build completion trigger.

If P0 fails, I do not want to trigger P1. There doesn't appear to be a way to add a condition to only trigger builds based on the successful completion of a previous build. We have to start P1 and cancel it based on a condition.
The only way I see to do this is via either:
- Setting an environment variable via a build script in P0,
Write-Host ("##vso[task.setvariable variable=BuildContinue;]$buildContinue"), and reading that variable via a script in P1 via a build task variable$(BuildContinue). - Setting a semaphore file as a build artifact in P0 and then downloading and reading that file in P1.
Both options require running the build. Is there a better way to conditionally run an Azure pipeline?
I've got two Azure pipelines, P0 and P1. Currently, P1 is triggered to run when P0 completes as a build completion trigger.

If P0 fails, I do not want to trigger P1. There doesn't appear to be a way to add a condition to only trigger builds based on the successful completion of a previous build. We have to start P1 and cancel it based on a condition.
The only way I see to do this is via either:
- Setting an environment variable via a build script in P0,
Write-Host ("##vso[task.setvariable variable=BuildContinue;]$buildContinue"), and reading that variable via a script in P1 via a build task variable$(BuildContinue). - Setting a semaphore file as a build artifact in P0 and then downloading and reading that file in P1.
Both options require running the build. Is there a better way to conditionally run an Azure pipeline?
edited Nov 14 '18 at 22:26
Michael Mainer
asked Nov 14 '18 at 21:21
Michael MainerMichael Mainer
2,2091823
2,2091823
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
We don't support conditional build completion triggers.
In the short term, your good options are:
- Pass along a flag in some form, as you suggested. Requires running the P1 build, but I don't see what harm that causes (you might have some reason why it's not suitable that I don't see).
- Unify the two pipelines into a single, multi-job pipeline. You probably have good reasons why you aren't doing that today, but you could block the P1 job from ever running by setting a condition.
- Instead of defining a P1 trigger that watches P0, have a step on P0 which uses the REST API to queue a run. This just barely qualifies as a "good" option – it meets the letter of your requirements but isn't very elegant.
Thank you @MattCooper
– Michael Mainer
Nov 26 '18 at 21:47
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308908%2fhow-can-i-conditionally-trigger-an-azure-pipeline-based-on-the-results-of-anothe%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
We don't support conditional build completion triggers.
In the short term, your good options are:
- Pass along a flag in some form, as you suggested. Requires running the P1 build, but I don't see what harm that causes (you might have some reason why it's not suitable that I don't see).
- Unify the two pipelines into a single, multi-job pipeline. You probably have good reasons why you aren't doing that today, but you could block the P1 job from ever running by setting a condition.
- Instead of defining a P1 trigger that watches P0, have a step on P0 which uses the REST API to queue a run. This just barely qualifies as a "good" option – it meets the letter of your requirements but isn't very elegant.
Thank you @MattCooper
– Michael Mainer
Nov 26 '18 at 21:47
add a comment |
We don't support conditional build completion triggers.
In the short term, your good options are:
- Pass along a flag in some form, as you suggested. Requires running the P1 build, but I don't see what harm that causes (you might have some reason why it's not suitable that I don't see).
- Unify the two pipelines into a single, multi-job pipeline. You probably have good reasons why you aren't doing that today, but you could block the P1 job from ever running by setting a condition.
- Instead of defining a P1 trigger that watches P0, have a step on P0 which uses the REST API to queue a run. This just barely qualifies as a "good" option – it meets the letter of your requirements but isn't very elegant.
Thank you @MattCooper
– Michael Mainer
Nov 26 '18 at 21:47
add a comment |
We don't support conditional build completion triggers.
In the short term, your good options are:
- Pass along a flag in some form, as you suggested. Requires running the P1 build, but I don't see what harm that causes (you might have some reason why it's not suitable that I don't see).
- Unify the two pipelines into a single, multi-job pipeline. You probably have good reasons why you aren't doing that today, but you could block the P1 job from ever running by setting a condition.
- Instead of defining a P1 trigger that watches P0, have a step on P0 which uses the REST API to queue a run. This just barely qualifies as a "good" option – it meets the letter of your requirements but isn't very elegant.
We don't support conditional build completion triggers.
In the short term, your good options are:
- Pass along a flag in some form, as you suggested. Requires running the P1 build, but I don't see what harm that causes (you might have some reason why it's not suitable that I don't see).
- Unify the two pipelines into a single, multi-job pipeline. You probably have good reasons why you aren't doing that today, but you could block the P1 job from ever running by setting a condition.
- Instead of defining a P1 trigger that watches P0, have a step on P0 which uses the REST API to queue a run. This just barely qualifies as a "good" option – it meets the letter of your requirements but isn't very elegant.
answered Nov 19 '18 at 19:31
Matt CooperMatt Cooper
726615
726615
Thank you @MattCooper
– Michael Mainer
Nov 26 '18 at 21:47
add a comment |
Thank you @MattCooper
– Michael Mainer
Nov 26 '18 at 21:47
Thank you @MattCooper
– Michael Mainer
Nov 26 '18 at 21:47
Thank you @MattCooper
– Michael Mainer
Nov 26 '18 at 21:47
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308908%2fhow-can-i-conditionally-trigger-an-azure-pipeline-based-on-the-results-of-anothe%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown