[JIRA] (JENKINS-47305) Dir Step doesn't work inside container step when dir is outside the workspace

3 views
Skip to first unread message

instruimran@gmail.com (JIRA)

unread,
Apr 16, 2018, 4:26:02 AM4/16/18
to jenkinsc...@googlegroups.com
Imran Noor Mohamed updated an issue
 
Jenkins / Bug JENKINS-47305
Dir Step doesn't work inside container step when dir is outside the workspace
Change By: Imran Noor Mohamed
 

When i use a dir step inside the container step i get allways a



error:
ERROR: script returned exit code -2
Finished: FAILURE
jenkinsfile
{code:java}
#!/usr/bin/env groovy

node {
   deleteDir()
   checkout scm

   def uniqueId = UUID.randomUUID().toString()

   stage('testing') {
     podTemplate(
       name: env.jaas_owner + '-jaas',
       label: uniqueId,
       containers: [
         containerTemplate(
           name: 'busybox',
           image: 'busybox',
           command: 'cat'
         )
       ]
     )
       {
         node(uniqueId) {
           container('busybox') {
             sh '''
             cd /var
             ls -al
             '''

             dir ('/var'){
               sh '''
               cd /var
               ls -al
               '''
             }
           }
         }
     }
   }
}{code}
 

 
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

knurek.j@gmail.com (JIRA)

unread,
Aug 22, 2018, 4:36:03 AM8/22/18
to jenkinsc...@googlegroups.com
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

jonas.falck@gmail.com (JIRA)

unread,
Apr 4, 2019, 3:09:02 AM4/4/19
to jenkinsc...@googlegroups.com

This seems to be an issue if we use multiple containers with container('golang')

{ dir("/go") }

Then the dir command seems to do it in jnlp container so i get a error that /go does not exist.

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

jonas.falck@gmail.com (JIRA)

unread,
Apr 4, 2019, 3:13:02 AM4/4/19
to jenkinsc...@googlegroups.com
Jonas Falck edited a comment on Bug JENKINS-47305
This seems to be an issue if we use multiple containers with container('golang'){
dir("/go")
}

Then the dir command seems to do it in jnlp container so i get a error that /go does not exist.

Please also note that environment variables existing in container golang is "null" if used
container('golang'){
  dir("${env.GOPATH}") <-- tries to cd into pwd()/null
  sh("echo $GOPATH" <-- echoes /go (WORKS)
}

jglick@cloudbees.com (JIRA)

unread,
Jul 16, 2019, 3:43:35 PM7/16/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jul 16, 2019, 3:46:02 PM7/16/19
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-47305
 
Re: Dir Step doesn't work inside container step when dir is outside the workspace

Sounds like a variant of JENKINS-33510; the dir step is not supported in this context, but the plugin fails to warn you that.

The solution is trivial: cd in your shell script.

jglick@cloudbees.com (JIRA)

unread,
Jul 16, 2019, 3:49:07 PM7/16/19
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Duplicate
 
Change By: Jesse Glick
Status: Open Resolved
Resolution: Duplicate
Reply all
Reply to author
Forward
0 new messages