What is the "container" keyword in Jenkins?

Viewed 4677

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.

3 Answers

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.

Related