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

Agent args cannot override default config on plugin

XMLWordPrintable

      When using agent docker into a jenkinsfile we can add some args to our file, like user, volume or other. 

      The actual behaviour when docker container start working is:

      [Pipeline] withDockerContainerJenkins does not seem to be running inside a container$ docker run -t -d -u 995:993 -w /var/lib/jenkins/workspace/Test/test-docker -v /var/lib/jenkins/workspace/Test/test-docker:/var/lib/jenkins/workspace/Test/test-docker:rw,z -v /var/lib/jenkins/workspace/Test/test-docker@tmp:/var/lib/jenkins/workspace/Test/test-docker@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** registry.gitlab.com/path/to/my/images/image:latest cat 

      However if on the jenkinsfile we set some args for user or volume, the expected behaviour should be to override the default ones, but instead is just adding more args to the docker run command:
      the jenkinsfile:

      pipeline {
          agent { 
              docker {
                  image 'path/to/my/images/image:latest'
                  registryUrl 'https://registry.gitlab.com'
                  args '-u 995:1000'
              }
          }

      The output:

      [Pipeline] withDockerContainerJenkins does not seem to be running inside a container$ docker run -t -d -u 995:993 -u 995:1000 -w /var/lib/jenkins/workspace/Test/test-docker -v /var/lib/jenkins/workspace/Test/test-docker:/var/lib/jenkins/workspace/Test/test-docker:rw,z -v /var/lib/jenkins/workspace/Test/test-docker@tmp:/var/lib/jenkins/workspace/Test/test-docker@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** registry.gitlab.com/path/to/my/images/image:latest cat

      This creates limitation for the plugin and does not allow to use all the power of docker.

       

      Possible solution:

      • set a way to override the default values or to do more configuration for the plugin
      • create some condition that if the jenkinsfile contains some args, do not set the default one but use the ones provided on the Jenkinsfile

            Unassigned Unassigned
            sdeponte saul
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: