As far as I've searched I don't see any documentation for loops and arrays for Concourse CI.
I'm trying to migrate a job from Jenkins to CI and the snippet of my Jenkins file
def folders = [
"roller",
"auth",
"Django",
"gitlab",
"Drone",
]
stage('tests & conv') {
when {
beforeAgent true
not {
branch 'master'
}
}
steps {
script {
parallel folders.collectEntries {
[
"tests ${i}" : {
stage("Test ${i}") {
sh "make ${i}"
}
},
"conv ${it}" : {
stage("Test ${i}") {
sh "make run ${i} "
}
},
]
}
}
}
}
How can I replicate the same in the Concourse pipeline.
I can define an array like below but unsure how to iterate thru them.
folders:
- roller
- auth
- Django
- gitlab
- Drone
This may not be the complete answer but should definitely start you off running in the right direction. You can in effect do what you need using Carvel YTT which automates the YAML creation. There is also a very handy playground on that site where you can check your workings, and it will show you what the generated YAML will look like.
Example
vars.yaml
:Example
schema.yaml
would then be:Your starting concourse Carvel-ytt
pipeline.yaml
could be:Now in the
pipeline.yaml
there is a lot going on here that is out of scope of your OP, but pretty neat. We use taylorsilva's carvel-ytt image and this creates thepipeline.yaml
that we point the concourseset-pipeline
command to generate the all the jobs. Thisself-configure
job will automatically trigger and update itself when you update its SCM. If you have any secret management set up then you can substitute the((variable references))
, otherwise replace them directly with what you need.