Multi job pipeline always checks out same commit?

Viewed 440

I have defined a multi job azure pipeline where every job needs to clone and checkout the source git repository. Some of these jobs can take a while so I am wondering if every job always clones and checks out the momentary HEAD version/commit of the Git branch or the pipeline trigger commit is remembered by the pipeline and then used for every job in order to have a consistent pipeline run.

I am pretty sure resp. can only hope the 2nd to be the case (and never saw anything else) but I am wondering if someone can point me to some Azure docs that officially confirm it.

3 Answers

When a pipeline is queued the ref is set. All jobs in the pipeline will checkout that reference. It's one of the reasons why the agent checks out the ref specifically and leaves the repo in detached HEAD state.

I can't find a doc that explicitly explains this, but that's how it works.

In a build pipeline (both YAML and Classic), by default each job in the pipeline will check out the commit version which triggered the current pipeline run.

In YAML pipeline, if you do not want a job to check out the commit ref, you can add the following step as the first one in the job.

steps:
- checkout: none
. . .

Both @Jesse and @Bright are right

There's a pipeline decorator that is evaluated on the first stage that looks for the presence of the checkout task. If the task is not found, it is dynamically inserted as the first step in the job.

You can see the pipeline decorator if you look at the top-level logs of the stage and expand the Job preparation parameters:

system-pre-steps.yml

By specifying the checkout task with different settings, you can prevent this task from being injected:

steps:
- checkout: none
Related