[JIRA] (JENKINS-57162) Additional build args not taken into account for image name for pipeline Dockerfile

3 views
Skip to first unread message

xistence@0x58.com (JIRA)

unread,
Apr 23, 2019, 9:17:02 PM4/23/19
to jenkinsc...@googlegroups.com
Bert JW Regeer created an issue
 
Jenkins / Bug JENKINS-57162
Additional build args not taken into account for image name for pipeline Dockerfile
Issue Type: Bug Bug
Assignee: Unassigned
Components: docker-workflow-plugin, pipeline
Created: 2019-04-24 01:16
Labels: pipeline docker-build-step docker
Priority: Blocker Blocker
Reporter: Bert JW Regeer

In https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/69e6f4af23665b6aee29fb050056463149122a82/pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy#L68

the hash for the the image to be built is computed, however this not properly take into account that we may use the same Dockerfile just with different build arguments to change the resulting image.

// Work-around for Jenkins not killing/removing older queued jobs
for (int i = 0; i < (BUILD_NUMBER as int); i++) {milestone()}

// What follows is the actual pipeline that we want Jenkins to go and build, along with all of the stages

pipeline {
    options {
        timeout(time: 1, unit: 'HOURS')
            timestamps()
    }

    agent none;

    stages {
        stage("Unit Testing") {
            parallel {
                stage("Python 3.7") {
                    agent {
                        dockerfile {
                            filename 'Dockerfile.jenkins'
                            additionalBuildArgs '--build-arg TAG=3.7'
                            label 'docker'
                        }
                    }
                    steps {
                        sh 'tox -e py37'
                        stash name: 'py37_coverage', includes: '.coverage.py37'
                    }
                    post {
                        always {
                            junit 'junit.xml'
                        }
                    }
                }
                stage("Python 3.6") {
                    agent {
                        dockerfile {
                            filename 'Dockerfile.jenkins'
                            additionalBuildArgs '--build-arg TAG=3.6'
                            label 'docker'
                        }
                    }
                    steps {
                        sh 'tox -e py36'
                        stash name: 'py36_coverage', includes: '.coverage.py36'
                    }
                    post {
                        always {
                            junit 'junit.xml'
                        }
                    }
                }
            }
        }
    }
}

Will both build an image that is going to be tagged with the exact same sha hash, which means that either one of them is going to end up executing inside the wrong docker container.

18:57:26 -0600  + docker build -t 1d1e61023e37853427ab75fc92cac3ab6e0d4c58 --build-arg TAG=3.7 -f Dockerfile.jenkins .
18:57:26 -0600  + docker build -t 1d1e61023e37853427ab75fc92cac3ab6e0d4c58 --build-arg TAG=3.6 -f Dockerfile.jenkins .
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

keitwb@gmail.com (JIRA)

unread,
May 27, 2019, 3:15:02 PM5/27/19
to jenkinsc...@googlegroups.com

keitwb@gmail.com (JIRA)

unread,
May 27, 2019, 3:15:02 PM5/27/19
to jenkinsc...@googlegroups.com
Ben Keith started work on Bug JENKINS-57162
 
Change By: Ben Keith
Status: Open In Progress

keitwb@gmail.com (JIRA)

unread,
May 27, 2019, 5:45:02 PM5/27/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages