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 'git.everest.canoga.com:5005/software-development/devops/docker-test:latest'
                    args '-t'
                }                
            }
            steps {
		sh 'ls -al'
                sh './shellscript.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=%22https://github.com/dockbuild/dockbuild%22%3Ehttps://github.com/dockbuild/dockbuild%3C/a%3E%20wit">https://github.com/dockbuild/dockbuild
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 './shellscript.sh' above actually doing something like

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

Or is it doing

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

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 https://groups.google.com/d/msgid/jenkinsci-users/1a71f448-95f9-42fe-9e89-271d186e27d1%40googlegroups.com.