I Need One Job to Wait for the Other Job to Finish

Aaron Jensen's Avatar

Aaron Jensen

17 Oct, 2019 09:39 PM

We use AppVeyor to build PowerShell modules. We can't use any of AppVeyor's deployments to deploy our modules, so we have to publish on our own. We've integrated this publishing into our build so that it only happens on the master branch.

We used to run a build on Linux then a build on Windows. We would publish from the Windows build. If the Linux build failed, the Windows build would never run and we would never publish.

We recently upgraded to a plan that allows parallel builds. Now, our Linux build and our Windows build are running in parallel. We don't want to publish if the Linux build fails. What do we do?

I found this code that supposedly lets one job wait for another job to finish. Unfortunately, it doesn't work if you've got two builds going at the same time. The https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG endpoint only returns the newest build, not all currently executing builds.

  1. Support Staff 1 Posted by Feodor Fitsner on 17 Oct, 2019 11:19 PM

    Feodor Fitsner's Avatar

    Hi Aaron,

    We have a solution for that! It's not yet publicly announced and documented, but AppVeyor supports chaining jobs, parallel job groups, fan in/out scenarios. Look at this template yaml for your specific case: https://gist.github.com/FeodorFitsner/ff5c34a72a42d492b900b05917c09... - it defines two jobs where Windows build job depends on Linux build job.

    You can see build results here: https://ci.appveyor.com/project/FeodorFitsner/simple-console/builds...

    I'm sure the yaml is self-descriptive, however please feel free to ask any questions.

    There are more advanced scenarios possible: https://gist.github.com/FeodorFitsner/8e55dd6142dd04503d070297bdc2b223

  2. 2 Posted by Aaron Jensen on 18 Oct, 2019 07:27 PM

    Aaron Jensen's Avatar

    Wow. That's great. Thank you.

    Is there somewhere I can make a feature request to extend your AppVeyor REST API to return information about all currently running builds and jobs? It can be a new endpoint or additional information on the current projects endpoint.

    I only need to synchronize/wait when publishing. We publish on branches, so on other branches, builds can run in parallel and end whenever they want. I wrote some PowerShell that waits, but it will fail if another build starts.

  3. Support Staff 3 Posted by Feodor Fitsner on 20 Oct, 2019 02:26 AM

    Feodor Fitsner's Avatar

    But you can use the same API as the list of projects: https://ci.appveyor.com/api/account/AppVeyor/projects/paged?pageInd... - it has the information about running builds.

  4. 4 Posted by Aaron Jensen on 21 Oct, 2019 07:23 PM

    Aaron Jensen's Avatar

    That API returns all running builds. Yay! However, it doesn't return any jobs information. Each active build has a jobs property, but it's empty, even though I can see in the UI that each build is running two jobs.

  5. Support Staff 5 Posted by Feodor Fitsner on 22 Oct, 2019 03:39 AM

    Feodor Fitsner's Avatar

    Indeed, job details are omitted from results (mostly due to performance optimizations). Looks like you should call build details API for the builds you need.

  6. 6 Posted by Aaron Jensen on 22 Oct, 2019 03:44 AM

    Aaron Jensen's Avatar

    What API is that? I can’t find it in your docs.

  7. Support Staff 7 Posted by Feodor Fitsner on 22 Oct, 2019 03:48 AM

    Feodor Fitsner's Avatar

    It's /api/projects/AppVeyor/appveyor/builds/{buildId}. You can always see API calls in browser developer console while navigating through UI - it uses the same API endpoints.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac