Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51576

Jenkinsfile with Dockerfile in a specific folder

    Details

    • Similar Issues:

      Description

      According to https://issues.jenkins-ci.org/browse/JENKINS-41668 this should work, but I simply cannot use a Dockerfile from a specific folder: the second argument seems to be ignored completely.

      This is driving me nuts: I am trying to build a Docker image from a Dockerfile in a specific folder of my repository using a scripted Jenkins Pipeline, but it doesn't get the correct path.

      This is the line in the Jenkinsfile:

      def customImage = docker.build("km3pipe:${env.BUILD_ID}", "-f ${dockerfile${DOCKER_FILES_DIR}")

      As you can see in the Jenkinslog below, the variables are correctly resolved (I also double checked the workspace, everything is fine), but it seems to ignore the second argument .dockerfiles and complains about symlinks?

      [py365] + docker build -t km3pipe:13 -f py365 ./dockerfiles
       [py365] unable to prepare context: unable to evaluate symlinks in Dockerfile path: 
              lstat /var/lib/jenkins/workspace/f-docker-image-names-for-ci-2DCL5RJ7AMH7K
              IB6OCBTD57EC5DUGYZTQE5EQ6KGOSPXMUOVJP6Q/py365: no such file or directory

      Any ideas what's going wrong here?

      P.S.: I could figure out yet how to create a proper code block...

        Attachments

          Activity

          Hide
          tamasgal Tamas Gal added a comment -

          A workaround was proposed by Ignacio Millán, see here: https://stackoverflow.com/questions/50578578/jenkinsfile-with-dockerfile-in-a-specific-folder

          Which works:

          def customImage = ''
          dir("${DOCKER_FILES_DIR}"){
          customImage = docker.build("km3pipe:${env.BUILD_ID}",
          "-f ${dockerfile} .")
          }

          Show
          tamasgal Tamas Gal added a comment - A workaround was proposed by Ignacio Millán , see here: https://stackoverflow.com/questions/50578578/jenkinsfile-with-dockerfile-in-a-specific-folder Which works: def customImage = '' dir("${DOCKER_FILES_DIR}"){ customImage = docker.build("km3pipe:${env.BUILD_ID}", "-f ${dockerfile} .") }

            People

            • Assignee:
              vjuranek vjuranek
              Reporter:
              tamasgal Tamas Gal
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: