I recently inherited a code base with some Jenkins files. In one of them I ran into this syntax
stage('Prepare database for integration tests') {
steps {
container('postgres') {
sh "..."
}
}
}
Our Jenkins is running on Openshift and the pod has multiple containers including this postgres one. However I can't find any references for using the container or connecting to a container with container('containerName') like that.
I tried to create a separate pipeline with the following piece
container('az-cli') {
try {
sh 'ls'
} catch (error) {
throw error
}
}
And ls listed the content in the code repository - not the container. Clearly container is not doing what I thought it does and I can't find any documentation on it. Does anyone know what this is supposed to do?
Thanks in advance.
Ok, It apparently comes from the Kubernetes plugin. More documentation is in this jenkins github repo and in this jenkins documentation.
And also it was working but the 'ls' command was deceiving. When I ran an actual Azure command I saw the command result also see the logs of the container.
Thank you everyone.
If the container(...) method is not documented it is likely being loaded by a custom library.
Check for the @Library annotation in your pipeline or if it is not part of an automatically loaded lib. You'll then find the groovy file where it is declared.
More info at https://jenkins.io/doc/book/pipeline/shared-libraries/#using-libraries
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With