Does the dir() rule ever work?

257 views
Skip to first unread message

Jay Miller

unread,
May 8, 2017, 11:37:24 AM5/8/17
to Jenkins Users
I have a pretty simple Jenkinsfile:

pipeline {
  agent { docker 'node:6.10' }
  environment {
    NPM_CONFIG_USERCONFIG = 'T2/.npmrc'
  }
  stages {
    stage('Packages') {
      steps {
        sh 'node -v'
        
        dir ('T2/bot') { 
          sh 'npm install'
        }
      }
    }
  }
}

When I hit the dir() rule, I see the following in the logs:

[Pipeline] dir
Running in ...USFQ/T2/bot
[Pipeline] {
[Pipeline] sh
[T2bot] Running shell script
JENKINS-33510: working directory will be ...USFQ not ..USFQ/T2/bot
+ npm install

JENKINS-33510 says: "dir('foo') inside 'docker.image().inside{}' does not affect CWD of launched processes".  My Jenkinsfile doesn't appear to have an image().inside block (right?), yet dir() is failing in the same way.

Does dir() ever work, or am I doing something particularly strange?

Thanks in advance for any help!

Christopher Orr

unread,
May 9, 2017, 5:34:00 AM5/9/17
to jenkins...@googlegroups.com
On Mon, 8 May 2017, at 16:32, Jay Miller wrote:
> JENKINS-33510 says:
> "dir('foo') inside 'docker.image().inside{}' does not affect CWD of
> launched processes". My Jenkinsfile doesn't appear to have an
> *image().inside* block (right?), yet *dir()* is failing in the same way.

That description of the issue comes from Scripted Pipeline syntax —
you're using the `agent { docker }` directive from the Declarative
Pipeline syntax, which probably causes the `image().inside` stuff to
happen under the hood. So that's likely why you're hitting that issue.

Regards,
Chris

Jay Miller

unread,
May 9, 2017, 9:55:50 AM5/9/17
to Jenkins Users
On Tuesday, May 9, 2017 at 3:34:00 AM UTC-6, Christopher Orr wrote:
That description of the issue comes from Scripted Pipeline syntax —
you're using the `agent { docker }` directive from the Declarative
Pipeline syntax, which probably causes the `image().inside` stuff to
happen under the hood.  So that's likely why you're hitting that issue.

Ah, that makes sense.  So the dir() rule is probably incompatible with the declarative syntax until that bug is fixed.

Bummer!

Thanks for the reply, Chris! 
Reply all
Reply to author
Forward
0 new messages