How can I conditionally trigger an Azure pipeline based on the results of another Azure pipeline?










0















I've got two Azure pipelines, P0 and P1. Currently, P1 is triggered to run when P0 completes as a build completion trigger.



enter image description here



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:



  1. 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).

  2. 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?










share|improve this question




























    0















    I've got two Azure pipelines, P0 and P1. Currently, P1 is triggered to run when P0 completes as a build completion trigger.



    enter image description here



    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:



    1. 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).

    2. 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?










    share|improve this question


























      0












      0








      0








      I've got two Azure pipelines, P0 and P1. Currently, P1 is triggered to run when P0 completes as a build completion trigger.



      enter image description here



      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:



      1. 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).

      2. 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?










      share|improve this question
















      I've got two Azure pipelines, P0 and P1. Currently, P1 is triggered to run when P0 completes as a build completion trigger.



      enter image description here



      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:



      1. 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).

      2. 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?







      azure-pipelines






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 22:26







      Michael Mainer

















      asked Nov 14 '18 at 21:21









      Michael MainerMichael Mainer

      2,2091823




      2,2091823






















          1 Answer
          1






          active

          oldest

          votes


















          1














          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.





          share|improve this answer























          • Thank you @MattCooper

            – Michael Mainer
            Nov 26 '18 at 21:47










          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
          );



          );













          draft saved

          draft discarded


















          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









          1














          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.





          share|improve this answer























          • Thank you @MattCooper

            – Michael Mainer
            Nov 26 '18 at 21:47















          1














          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.





          share|improve this answer























          • Thank you @MattCooper

            – Michael Mainer
            Nov 26 '18 at 21:47













          1












          1








          1







          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.





          share|improve this answer













          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.






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 19:31









          Matt CooperMatt Cooper

          726615




          726615












          • 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





          Thank you @MattCooper

          – Michael Mainer
          Nov 26 '18 at 21:47



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          27

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          Category:Rhetoric