I have exactly the same problem as you.
There is no real solution to this need in gitlabci because the solution has been designed to work with "perennial" runners and not "ephemeral" instances like AWS SPOT.
And in the case of a perennial runner this problem does not arise because the "stages" that follow can reuse the configurations made by the previous "stages" on the same machine
In my case I found 2 possible workarounds
- Reproduce the steps (implemented in my company)
This method consists in reproducing actions that we have already done in previous "courses".
Advantage: Teams are not lost in the pipeline GUI and can see each "stage" as a separate job
Disadvantage: We take more time during deployment because the last job of the last "stage" redoes all the actions of the previous job on the runner it uses
Here is a code example to illustrate the solution (using the
!reference
system)
.scriptCheckHelm:
script:
- 'helm dependency build'
- 'helm lint .'
stages:
- lint
- build
Check_Conf:
stage: 'lint'
script:
- !reference [.scriptCheckHelm, script]
rules:
- if: '($CI_PIPELINE_SOURCE == "push")'
when: 'always'
allow_failure: false
extends: .tags
Build_Package:
stage: 'build'
script:
- !reference [.scriptCheckHelm, script]
- 'helm package .'
rules:
- if: '($CI_PIPELINE_SOURCE == "push")&&($CI_COMMIT_TITLE == "DEPLOYMENT")'
when: 'on_success'
allow_failure: false
extends: .tags
In this case, when we make commit with title "DEPLOYMENT", we had :
PIPELINE with multiple job
- Run a single job
This method consists in grouping all the actions in a single job
Advantage : No time loss during a deployment, the runner executes all the actions one after the other
Disadvantage: Users see only one job and have to look in the job log to identify the error
.scriptCheckHelm:
script:
- 'helm dependency build'
- 'helm lint .'
stages:
- lint
- build
Check_Conf:
stage: 'lint'
script:
- !reference [.scriptCheckHelm, script]
rules:
- if: '($CI_PIPELINE_SOURCE == "push")&&($CI_COMMIT_TITLE != "DEPLOYMENT")'
when: 'always'
allow_failure: false
extends: .tags
Build_Package:
stage: 'build'
script:
- !reference [.scriptCheckHelm, script]
- 'helm package .'
rules:
- if: '($CI_PIPELINE_SOURCE == "push")&&($CI_COMMIT_TITLE == "DEPLOYMENT")'
when: 'on_success'
allow_failure: false
extends: .tags
In this case, when we make commit with title "DEPLOYMENT", we had :
PIPELINE with 1 job
builds-images
tag to another runner going to help fix this problem? And how is it different from the tagitela-spot-runner
already defined? – Benzol