Question on enviroment in pipeline build with Docker

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Question on enviroment in pipeline build with Docker

Brett Bergquist
I have a pipeline build and steps are using a docker image. A test stage

        stage('Build') {
            agent {
                docker { 
                    image ''
                    args '-t'
            steps {
		sh 'ls -al'
                sh './'

The docker image has an "entrypoint" that sources in a script to setup for a cross compiler (yocto environment script). I can use this image outside of Jenkins with no issue to run make, compilation, etc. as the environment is setup correctly by the entrypoint sourcing the script. This docker image is based off
<a href="mail://82f72c016149a3c929f3374707af0aa04bc997cb/Sent%20Items/%3Ca%20href=%22">
with some slight modifications. 

When I try to use this docker image in Jenkins to perform a build, the environment is not setup. Jenkins starts a detached container that stays running in the background from the image and then uses what I assume to be "docker exec" equivalent to execute the steps in the container. Unfortunately when done this way, the environment that was setup by the "entrypoint" is not in effect. 

The environment that is setup through sourcing the yocto environment script is not easily replicated by using the ENV command of the Dockerfile and it changes depending on yocto build and will become maintenance issue if I try to do so. So my question is, is there some way to get this environment script sourced so that the pipeline steps will have the environment that I don't know about? A second question, is the "sh './' above actually doing something like

docker exec -t <container> sh -c ./

Or is it doing

docker exec -t <container> ./

I believe Jenkins is using docker in this fashion to start the container once for the duration of the stage and then execute the steps using the "docker exec" but this really does have an issue with it bypassing the carefully constructed "entrypoint" that might exist for the image.

Any help will be greatly appreciated.

You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit