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

agent docker parameters do not honor the current environment

    XMLWordPrintable

Details

    Description

      Currently I need to use multiple docker containers which need to be linked together.
      I tried using the --link option to set the linked image. In my use-case I don't want to set a fixed name but need to use a variable for the name.

      In this case the args parameter is evaluated to "--link null:linkedimage" and the job fails.

      Or is there another way to pass dynamic parameters (from variables) to the docker args?

      pipeline {
          agent any
          environment {
              LINK_DOCKER_IMAGE = "linkedimage"
          }
          stages {
              stage ('Compose') {
                  agent {
                     docker {
                          image 'alpine'
                          args  "--link ${env.LINK_DOCKER_IMAGE}:linkedimage"
                      }
                  }
                  steps {
                          sh 'printenv'
                  }
              }
          }
      }
      

      Attachments

        Activity

          vfratila Vlad Fratila added a comment -

          It would be great for env vars to work with env vars.

          vfratila Vlad Fratila added a comment - It would be great for env vars to work with env vars.
          jomach Jorge Machado added a comment -

          I have another use case for this. Running builds with nvidia-docker we need to pass NV_GPU= 0,1 at container start ... This does not work with the environment directive

          jomach Jorge Machado added a comment - I have another use case for this. Running builds with nvidia-docker we need to pass NV_GPU= 0,1 at container start ... This does not work with the environment directive
          pjung Philipp Jung added a comment -

          Same issue here. Any chance to change the priority?

          pjung Philipp Jung added a comment - Same issue here. Any chance to change the priority?
          omerfsen Omer Sen added a comment - - edited

          Same issue here. Any chance to change the priority? 

           

          Also haven't used it but some one found a workaround for this

           

          https://stackoverflow.com/questions/53882492/jenkins-how-to-use-variables-inside-agent-docker-args

          omerfsen Omer Sen added a comment - - edited Same issue here. Any chance to change the priority?    Also haven't used it but some one found a workaround for this   https://stackoverflow.com/questions/53882492/jenkins-how-to-use-variables-inside-agent-docker-args
          sergi_mus Sergi Mus added a comment -

          Please fix.

          sergi_mus Sergi Mus added a comment - Please fix.

          People

            Unassigned Unassigned
            sven_carstens_udg Sven Carstens
            Votes:
            25 Vote for this issue
            Watchers:
            27 Start watching this issue

            Dates

              Created:
              Updated: