Reputation: 145
I have a YAML script that looks something like this:
jobs:
- job: UnixBuild
pool:
name: BuildMachinesUnix
steps:
- bash: echo "Build Unix"
- job: WinBuild
pool:
name: BuildMachinesWindows
steps:
- bash: echo "Build Windows"
- job: UnixRelease
dependsOn:
- UnixBuild
- WinBuild
condition: and(succeeded('UnixBuild'), succeeded('WinBuild'))
pool:
name: BuildMachinesUnix
steps:
- bash: echo "Release on Unix"
- job: WinRelease
dependsOn:
- UnixBuild
- WinBuild
condition: and(succeeded('UnixBuild'), succeeded('WinBuild'))
pool:
name: BuildMachinesWindows
steps:
- bash: echo "Release on Windows"
Each Pool has several agent, and I want the Agent that took on the UnixBuild job to also handle the UnixRelease job, as all the files for that release is there, so that I don't needto rebuild it, in the release step, and the same goes from the WindowsBuild
Is such a thing possible, if so how?
If not, have any good suggestion for how to only release if both Unix and Windows succedes, without having to compile it twice?
Upvotes: 2
Views: 3588
Reputation: 76928
I want the Agent that took on the UnixBuild job to also handle the UnixRelease job, as all the files for that release is there, so that I don't needto rebuild it, in the release step, and the same goes from the WindowsBuild
The answer is yes.
To resolve this issue, we could get the agent name from the UnixBuild
job, then pass this as demands
:
- job: UnixBuild
pool:
name: BuildMachinesUnix
steps:
- bash: echo "$(Agent.Name)"
- bash: |
echo "##vso[task.setvariable variable=someName;isOutput=true;]$(Agent.Name)"
name: setVariable
- job: UnixRelease
dependsOn:
- UnixBuild
- WinBuild
condition: and(succeeded('UnixBuild'), succeeded('WinBuild'))
variables:
TestsomeName: $[ dependencies.UnixBuild.outputs['setVariable.someName'] ]
pool:
name: BuildMachinesUnix
demands:
- Agent.Name -equals $(TestsomeName)
steps:
- bash: echo "$(TestsomeName)"
Upvotes: 7