Reputation: 1245
I have a ci pipeline which triggers when a PR gets merged, checks out the code, increments the application's build number, and then commits it.
I then have a build pipeline meant to trigger after that pipeline completes:
resources:
pipelines:
- pipeline: increment-pipeline
source: increment-version
trigger: true
The issue is that when the build pipeline triggers, it runs on the commit that the increment pipeline had checked out, not the commit that it pushed.
According to the Azure Devops docs:
If the triggering pipeline and the triggered pipeline use the same repository, both pipelines will run using the same commit when one triggers the other. This is helpful if your first pipeline builds the code and the second pipeline tests it. However, if the two pipelines use different repositories, the triggered pipeline will use the version of the code in the branch specified by the Default branch for manual and scheduled builds setting, as described in Branch considerations for pipeline completion triggers.
This is sane, except that we increment our version with a commit to master before triggering a build that should build off of that incremented commit. The trouble is, with my yaml pipelines this is what ends up happening:
n
to n+1
, commits, pushes to mastern
, and builds n
instead of n+1
, pushing the artifacts to our active directory.The trick of it is we have a classic pipeline I'm trying to replace doing it correctly, with the classic build pipeline building n+1
. I can't figure out how to make the yaml conform to the n+1
build technique.
A simple solution is to not checkout self and instead checkout master, but we sometimes run the build pipeline manually on branches other than master, and we also use it as ci/cd on branches other than master triggered by the increment-version pipeline.
So the crux of it is, how can I update the repository to the latest on the current branch in azure devops?
Upvotes: 0
Views: 766
Reputation: 1089
There is a checkout
task which you can use to checkout any repo, and also a specific ref/branch thereof:
https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#checking-out-a-specific-ref
Upvotes: 1