Skip to content

Commit b0efb9c

Browse files
authored
cancel pipeline on tag change (#1661)
* test repo trigger * add resources label * add repositories under resources * test with endpoint * testing with tag check * typo in condition line * evaulate version in condition * compare tag vars * test cancellation stage * add job to cancel stage * change name of cancel stage * add pool and msg to cancel job * change cancellation dependency * add second tag validation stage * spcaing ofvalidation1 * test ne and cancellation script * check tag versions * set currentTagx variable * test new tag var * fix value mapping * check_tag job * update current tag in manifest stage * reading tags * adjust variable assignment * uncomment sleep * read out different tags * test validation dependency * use succeeded/failed in condition check * fix condition * fix call to succeeded() * omit condition on validation stages to read tags * remove sleep, just validate condition * fix error with submod swift naming
1 parent d2f7483 commit b0efb9c

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

.pipelines/pipeline.yaml

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,45 @@ stages:
239239
name: $(name)
240240
arch: $(arch)
241241
tag: $(TAG)
242+
- job: check_tag
243+
displayName: Check Tag
244+
pool:
245+
name: $(BUILD_POOL_NAME_DEFAULT)
246+
steps:
247+
- script: |
248+
echo "##vso[task.setvariable variable=currentTagBuild;isOutput=true]$(make version)"
249+
name: "CurrentTagBuild"
250+
displayName: "Set current tag variable"
251+
condition: always()
242252
253+
- stage: validate1
254+
displayName: Validate Tags
255+
dependsOn:
256+
- setup
257+
- containerize
258+
variables:
259+
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
260+
CURRENT_VERSION: $[ stagedependencies.containerize.check_tag.outputs['CurrentTagBuild.currentTagBuild'] ]
261+
condition: ne(variables.TAG, variables.CURRENT_VERSION)
262+
jobs:
263+
- job: timeout_and_cancel
264+
displayName: Cancel Run
265+
pool:
266+
name: $(BUILD_POOL_NAME_DEFAULT)
267+
steps:
268+
- script: |
269+
echo $TAG
270+
echo $CURRENT_VERSION
271+
echo "Checking if branch up to date with master"
272+
243273
- stage: publish
244274
displayName: Publish Multiarch Manifests
245275
dependsOn:
246276
- containerize
277+
variables:
278+
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
279+
CURRENT_VERSION: $[ stagedependencies.containerize.check_tag.outputs['CurrentTagBuild.currentTagBuild'] ]
280+
condition: and(succeeded(), eq(variables.TAG, variables.CURRENT_VERSION))
247281
jobs:
248282
- job: manifest
249283
displayName: Compile Manifests
@@ -272,7 +306,16 @@ stages:
272306
name: $(name)
273307
platforms: $(platforms)
274308
tag: $(TAG)
275-
309+
- job: check_tag
310+
displayName: Check Tag
311+
pool:
312+
name: $(BUILD_POOL_NAME_DEFAULT)
313+
steps:
314+
- script: |
315+
echo "##vso[task.setvariable variable=currentTagManifests;isOutput=true]$(make version)"
316+
name: "CurrentTagManifests"
317+
displayName: "Set current tag variable"
318+
condition: always()
276319
277320
- template: singletenancy/cilium/cilium-e2e-job-template.yaml
278321
parameters:
@@ -319,6 +362,26 @@ stages:
319362
clusterDefinitionCniBuildOS: "windows"
320363
clusterDefinitionCniBuildExt: ".zip"
321364

365+
- stage: validate2
366+
displayName: Validate Tags
367+
dependsOn:
368+
- setup
369+
- publish
370+
variables:
371+
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
372+
CURRENT_VERSION: $[ stagedependencies.publish.check_tag.outputs['CurrentTagManifests.currentTagManifests'] ]
373+
condition: ne(variables.TAG, variables.CURRENT_VERSION)
374+
jobs:
375+
- job: timeout_and_cancel
376+
displayName: Cancel Run
377+
pool:
378+
name: $(BUILD_POOL_NAME_DEFAULT)
379+
steps:
380+
- script: |
381+
echo $TAG
382+
echo $CURRENT_VERSION
383+
echo "Checking if branch is up to date with master"
384+
322385
- stage: cleanup
323386
displayName: Cleanup
324387
dependsOn:

.pipelines/singletenancy/aks-swift/e2e-job-template.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ stages:
1111
dependsOn:
1212
- setup
1313
- publish
14+
variables:
15+
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
16+
CURRENT_VERSION: $[ stagedependencies.containerize.check_tag.outputs['CurrentTagManifests.currentTagManifests'] ]
17+
condition: and(succeeded(), eq(variables.TAG, variables.CURRENT_VERSION))
1418
jobs:
1519
- job: ${{ parameters.name }}
1620
displayName: Singletenancy AKS Swift Suite - (${{ parameters.name }})

.pipelines/singletenancy/cilium/cilium-e2e-job-template.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ stages:
1111
dependsOn:
1212
- setup
1313
- publish
14+
variables:
15+
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
16+
CURRENT_VERSION: $[ stagedependencies.containerize.check_tag.outputs['CurrentTagManifests.currentTagManifests'] ]
17+
condition: and(succeeded(), eq(variables.TAG, variables.CURRENT_VERSION))
1418
jobs:
1519
- job: ${{ parameters.name }}
1620
displayName: Cilium Test Suite - (${{ parameters.name }})

.pipelines/submodules-pipeline.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ stages:
260260
displayName: AKS Swift
261261
pipelineBuildImage: "$(BUILD_IMAGE)"
262262
testDropgz: true
263-
clusterName: "submodules-swifte2e"
263+
clusterName: "submodswift"
264264
osSku: "Ubuntu"
265265

266266
- stage: cleanup

0 commit comments

Comments
 (0)