Reputation: 9194
Ultimately, I'm trying to do this:
azure-pipelines.yaml
and associated templates out of the code repository (code-repo
).pipeline-repo
).pipeline-repo
, but run the pipeline on the code in the code-repo
.I'm referring the following documentation:
code-repo
is just purely application code... and the Dockerfile
.repositories
resourceFor testing, I have this simple test.yaml
:
# Triggers when PR is created due to branch policies
trigger: none
resources:
repositories:
- repository: code-repo
type: git
name: code-repo
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Testing
displayName: Test stage
jobs:
- job: ParallelA
steps:
- bash: echo Hello from parallel job A
displayName: 'Run a one-line script'
When I create a PR on code-repo
, it is triggering the pipeline, which is to say branch policies are configured to refer to that pipeline. I do get the print out the Hello from parallel job A
print out.
But I don't see in the run logs it pulling code-repo
.
I do see the following, however:
My actual PR pipeline would look something like this:
trigger: none
resources:
repositories:
- repository: code-repo
type: git
name: code-repo
variables:
- template: templates/variables.yaml
pool:
vmIMage: $(vmImageName)
stages:
- template: templates/build/buildStage.yaml
...
Testing that, it confirms that it isn't running on the code-repo
PR, but the pipeline-repo
so everything fails.
So it is unclear to me what I need to do from here to get the pipeline to run on the PR code from code-repo
.
Suggestions?
Upvotes: 3
Views: 1047
Reputation: 9194
Ok, I think I have it sorted out, at least some of my stages are now succeeding.
I came across this documentation which informed me of checkout
.
So in addition to doing something like:
resources:
repositories:
- repository: code-repo
type: git
name: code-repo
Then you need to add a step
called checkout
like the following:
# Triggers when PR is created due to branch policies
trigger: none
resources:
repositories:
- repository: code-repo
type: git
name: code-repo
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Testing
displayName: Test stage
jobs:
- job: ParallelA
steps:
- checkout: code-repo
- task: task1
- task: task2
The checkout
should set the context for the subsequent steps.
Upvotes: 2