[JIRA] (JENKINS-49466) job directory empty when using declarative pipeline

1 view
Skip to first unread message

jenkins.io@veggiechinese.net (JIRA)

unread,
Feb 8, 2018, 6:32:03 PM2/8/18
to jenkinsc...@googlegroups.com
Will Yardley created an issue
 
Jenkins / Bug JENKINS-49466
job directory empty when using declarative pipeline
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2018-02-08 23:31
Environment: Jenkins 2.104 via official RPM on CentOS 7.4.1708.
Java: java-1.8.0-openjdk-1.8.0.161-0.b14
Plugins:
org.jenkins-ci.main:jenkins-war:2.104
org.jenkins-ci:crypto-util:1.1
commons-httpclient:commons-httpclient:3.1-jenkins-1
aopalliance:aopalliance:1.0
org.kohsuke.stapler:stapler-jelly:1.254
com.google.inject:guice:4.0
org.jenkins-ci.modules:slave-installer:1.6
org.springframework:spring-dao:1.2.9
org.jenkins-ci.modules:instance-identity:2.1
org.jenkins-ci:constant-pool-scanner:1.2
org.connectbot.jbcrypt:jbcrypt:1.0.0
org.jenkins-ci.modules:ssh-cli-auth:1.4
org.ow2.asm:asm-commons:5.0.3
org.jenkins-ci:symbol-annotation:1.1
com.github.jnr:jnr-constants:0.9.8
org.jenkins-ci.modules:windows-slave-installer:1.9.2
commons-digester:commons-digester:2.1
commons-io:commons-io:2.4
org.kohsuke:trilead-putty-extension:1.2
commons-codec:commons-codec:1.9
org.kohsuke:libzfs:0.8
org.jenkins-ci.ui:jquery-detached:1.2
org.kohsuke.stapler:json-lib:2.4-jenkins-2
org.jvnet.robust-http-client:robust-http-client:1.2
org.ow2.asm:asm:5.0.3
net.java.sezpoz:sezpoz:1.12
org.kohsuke.stapler:stapler-adjunct-timeline:1.5
org.jenkins-ci:winstone:4.1
org.slf4j:log4j-over-slf4j:1.7.25
org.jenkins-ci:version-number:1.4
org.codehaus.groovy:groovy-all:2.4.11
org.jvnet.hudson:commons-jelly-tags-define:1.0.1-hudson-20071021
org.jenkins-ci:jmdns:3.4.0-jenkins-3
commons-lang:commons-lang:2.6
org.springframework:spring-jdbc:1.2.9
org.codehaus.woodstox:wstx-asl:3.2.9
org.springframework:spring-core:2.5.6.SEC03
org.springframework:spring-aop:2.5.6.SEC03
org.samba.jcifs:jcifs:1.3.17-kohsuke-1
org.jenkins-ci:bytecode-compatibility-transformer:1.8
org.jenkins-ci.main:jenkins-core:2.104
com.sun.solaris:embedded_su4j:1.1
javax.inject:javax.inject:1
org.jenkins-ci.modules:upstart-slave-installer:1.1
org.apache.commons:commons-compress:1.10
commons-beanutils:commons-beanutils:1.8.3
org.jvnet.localizer:localizer:1.24
org.fusesource.jansi:jansi:1.11
org.jenkins-ci.main:cli:2.104
org.springframework:spring-beans:2.5.6.SEC03
javax.xml.stream:stax-api:1.0-2
org.slf4j:slf4j-jdk14:1.7.25
org.jvnet.hudson:activation:1.1.1-hudson-1
commons-jelly:commons-jelly-tags-fmt:1.0
net.i2p.crypto:eddsa:0.2.0
jfree:jfreechart:1.0.9
org.jenkins-ci:task-reactor:1.4
org.apache.ant:ant-launcher:1.8.4
org.apache.sshd:sshd-core:1.6.0
oro:oro:2.0.8
org.jenkins-ci:commons-jexl:1.1-jenkins-20111212
org.kohsuke.stapler:stapler-jrebel:1.254
org.jenkins-ci.plugins.icon-shim:icon-set:1.0.5
stax:stax-api:1.0.1
com.google.code.findbugs:jsr305:2.0.1
org.kohsuke.stapler:stapler:1.254
org.kohsuke:windows-package-checker:1.2
org.acegisecurity:acegi-security:1.0.7
org.jenkins-ci.main:remoting:3.16
org.jenkins-ci.modules:sshd:2.3
commons-fileupload:commons-fileupload:1.3.1-jenkins-2
org.jenkins-ci.modules:launchd-slave-installer:1.2
org.jenkins-ci:annotation-indexer:1.12
org.kohsuke:libpam4j:1.8
jline:jline:2.12
com.github.jnr:jffi:1.2.15
org.kohsuke.stapler:stapler-adjunct-zeroclipboard:1.3.5-1
org.kohsuke.stapler:stapler-adjunct-codemirror:1.3
org.ow2.asm:asm-util:5.0.3
org.slf4j:jcl-over-slf4j:1.7.25
org.kohsuke:access-modifier-annotation:1.12
org.kohsuke:akuma:1.10
org.kohsuke.stapler:stapler-groovy:1.254
javax.mail:mail:1.4.4
org.hamcrest:hamcrest-core:1.3
jfree:jcommon:1.0.12
org.springframework:spring-context-support:2.5.6.SEC03
com.google.guava:guava:11.0.1
org.jvnet.hudson:jtidy:4aug2000r7-dev-hudson-1
org.jenkins-ci:commons-jelly:1.1-jenkins-20120928
org.jenkins-ci.ui:handlebars:1.1.1
org.springframework:spring-context:2.5.6.SEC03
org.jenkins-ci.ui:jquery-detached:1.2.1
org.ow2.asm:asm-analysis:5.0.3
io.github.stephenc.crypto:self-signed-cert-generator:1.0.0
com.github.jnr:jffi:1.2.15
org.jvnet.winp:winp:1.25
javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1
commons-discovery:commons-discovery:0.4
org.jenkins-ci.dom4j:dom4j:1.6.1-jenkins-4
org.jenkins-ci:memory-monitor:1.9
org.jenkins-ci.modules:systemd-slave-installer:1.1
org.jvnet.hudson:xstream:1.4.7-jenkins-1
org.jvnet:tiger-types:2.2
com.sun.xml.txw2:txw2:20110809
org.springframework:spring-web:2.5.6.SEC03
org.kohsuke.jinterop:j-interop:2.0.6-kohsuke-1
org.jruby.ext.posix:jna-posix:1.0.3-jenkins-1
com.github.jnr:jnr-ffi:2.1.4
com.github.jnr:jnr-posix:3.0.41
javax.annotation:javax.annotation-api:1.2
org.kohsuke.jinterop:j-interopdeps:2.0.6-kohsuke-1
com.infradna.tool:bridge-method-annotation:1.13
org.ow2.asm:asm-tree:5.0.3
args4j:args4j:2.0.31
org.kohsuke:asm5:5.0.1
antlr:antlr:2.7.6
relaxngDatatype:relaxngDatatype:20020414
com.jcraft:jzlib:1.1.3-kohsuke-1
org.jenkins-ci.ui:bootstrap:1.3.2
commons-collections:commons-collections:3.2.2
net.java.dev.jna:jna:4.2.1
junit:junit:4.12
org.jenkins-ci:trilead-ssh2:build-217-jenkins-11
org.slf4j:slf4j-api:1.7.25
net.sf.ezmorph:ezmorph:1.0.6
org.apache.ant:ant:1.8.4
org.springframework:spring-webmvc:2.5.6.SEC03
com.github.jnr:jnr-x86asm:1.0.2
xpp3:xpp3:1.1.4c
jaxen:jaxen:1.1-beta-11
commons-jelly:commons-jelly-tags-xml:1.1
Priority: Minor Minor
Reporter: Will Yardley

I'm creating a job with a declarative pipeline; I'm coming across an issue similar to:

https://issues.jenkins-ci.org/browse/JENKINS-42440

only with a declarative pipeline. Jenkins does automagically check out the code, but it ends up in a

$WORKSPACE/foo_pipeline-XXXXX@script

directory instead of

$WORKSPACE/foo_pipeline-XXXXX
giving an error like:

Running on Jenkins in /var/lib/jenkins/workspace/foo_pipeline-XXXXX
[...]
java.io.FileNotFoundException: /var/lib/jenkins/workspace/foo_pipeline-XXXXX/package.json does not exist.
	at org.jenkinsci.plugins.pipeline.utility.steps.json.ReadJSONStepExecution.doRun(ReadJSONStepExecution.java:69)
	at org.jenkinsci.plugins.pipeline.utility.steps.json.ReadJSONStepExecution.doRun(ReadJSONStepExecution.java:45)
	at org.jenkinsci.plugins.pipeline.utility.steps.AbstractFileOrTextStepExecution.run(AbstractFileOrTextStepExecution.java:23)
	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
	at hudson.security.ACL.impersonate(ACL.java:290)
	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
pipeline {
  agent any
  parameters {
    choice(choices: 'foo\nbar',
           description: 'Which package to build',
           name: 'packageType'
    )
  }
  stages {
    stage('Build and push image') {
      steps {
        script {
          // requires "Pipeline Utility Steps" plugin
          def packageJson = readJSON file:'package.json'

          echo "${packageJson.version}"
          // more stuff here
        }
      }
    }

  }
  post {
    always {
      // Uses Workspace Cleanup plugin
      cleanWs()
    }
  }
}
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

jenkins.io@veggiechinese.net (JIRA)

unread,
Feb 8, 2018, 6:34:02 PM2/8/18
to jenkinsc...@googlegroups.com
Will Yardley updated an issue
Change By: Will Yardley
I'm creating a job with a declarative pipeline; I'm coming across an issue similar to:

https://issues.jenkins-ci.org/browse/JENKINS-42440

only with a declarative pipeline. Jenkins does automagically check out the code, but it ends up in a

{{$WORKSPACE/foo_pipeline-XXXXX@script}}

directory instead of

{{$WORKSPACE/foo_pipeline-XXXXX}}
giving an error like:

{noformat}

Running on Jenkins in /var/lib/jenkins/workspace/foo_pipeline-XXXXX
[...]
java.io.FileNotFoundException: /var/lib/jenkins/workspace/foo_pipeline-XXXXX/package.json does not exist.
at org.jenkinsci.plugins.pipeline.utility.steps.json.ReadJSONStepExecution.doRun(ReadJSONStepExecution.java:69)
at org.jenkinsci.plugins.pipeline.utility.steps.json.ReadJSONStepExecution.doRun(ReadJSONStepExecution.java:45)
at org.jenkinsci.plugins.pipeline.utility.steps.AbstractFileOrTextStepExecution.run(AbstractFileOrTextStepExecution.java:23)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
{noformat}

{code}

pipeline {
  agent any
  parameters {
    choice(choices: 'foo\nbar',
           description: 'Which package to build',
           name: 'packageType'
    )
  }
  stages {
    stage('Build and push image') {
      steps {
        script {
          // requires "Pipeline Utility Steps" plugin
          def packageJson = readJSON file:'package.json'

          echo "${packageJson.version}"
          // more stuff here
        }
      }
    }

  }
  post {
    always {
      // Uses Workspace Cleanup plugin
      cleanWs()
    }
  }
}
{code}

This was easy to miss when I wasn't clearing out the job workspace each time, but I think that would actually have been worse, since I'm guessing Jenkins was looking in one place, but running / changing things in the other.

jenkins.io@veggiechinese.net (JIRA)

unread,
Feb 8, 2018, 6:51:03 PM2/8/18
to jenkinsc...@googlegroups.com
Will Yardley commented on Bug JENKINS-49466
 
Re: job directory empty when using declarative pipeline

If I print out env.WORKSPACE either inside or outside of the script block, I get the same value as Running on Jenkins in /var/lib/jenkins/workspace/foo_pipeline-XXXXX, but that directory is empty if I don't clean it out after builds, whereas the one with @script has the checked out copy.

jenkins.io@veggiechinese.net (JIRA)

unread,
Feb 8, 2018, 6:53:02 PM2/8/18
to jenkinsc...@googlegroups.com
Will Yardley edited a comment on Bug JENKINS-49466
If I print out {{env.WORKSPACE}} either inside or outside of the script block, I get the same value as {{Running on Jenkins in /var/lib/jenkins/workspace/foo_pipeline-XXXXX}}, but that directory is empty if I don't clean it out after builds, whereas the one with {{@script}} has the checked out copy.

I tried adding a {{checkout SCM}} stage, then I get:
{{ERROR: Could not determine exact tip revision of pipeline}}

o.v.nenashev@gmail.com (JIRA)

unread,
Feb 12, 2018, 4:36:02 AM2/12/18
to jenkinsc...@googlegroups.com
Oleg Nenashev updated an issue
 
Change By: Oleg Nenashev
Component/s: pipeline-model-definition-plugin

andrew.bayer@gmail.com (JIRA)

unread,
Feb 12, 2018, 7:53:03 AM2/12/18
to jenkinsc...@googlegroups.com
Andrew Bayer resolved as Duplicate
Change By: Andrew Bayer
Status: Open Resolved
Resolution: Duplicate

jenkins.io@veggiechinese.net (JIRA)

unread,
Feb 13, 2018, 7:53:02 PM2/13/18
to jenkinsc...@googlegroups.com
Will Yardley reopened an issue
Change By: Will Yardley
Resolution: Duplicate
Status: Resolved Reopened

jenkins.io@veggiechinese.net (JIRA)

unread,
Feb 13, 2018, 7:54:02 PM2/13/18
to jenkinsc...@googlegroups.com
Will Yardley commented on Bug JENKINS-49466
 
Re: job directory empty when using declarative pipeline

I don't think this is a dupe of JENKINS-40862 – the error in the comment only shows up if I try to work around the problem by adding "checkout scm" in the Jenkinsfile.

andrew.bayer@gmail.com (JIRA)

unread,
Feb 15, 2018, 3:07:03 PM2/15/18
to jenkinsc...@googlegroups.com

Will Yardley - so I'm 99% sure that this is the same thing. We do an automatic checkout scm whenever you go to a new agent, but only if the skipDefaultCheckout option isn't specified and the scm object exists/is valid. The Could not determine exact tip revision of pipeline error message is, basically, what happens when you try to do a checkout scm on a null or otherwise broken scm object - you don't see that show up without the explicit checkout scm because Declarative doesn't even try doing it when the scm object is null/invalid.

jenkins.io@veggiechinese.net (JIRA)

unread,
Feb 15, 2018, 3:53:02 PM2/15/18
to jenkinsc...@googlegroups.com

Andrew Bayer In the case where it's not explicit, the code does get checked out, though. Just that it ends up in foo@script instead of foo. So the code gets checked out, just not to the place where Jenkins expects it to be.

andrew.bayer@gmail.com (JIRA)

unread,
Feb 20, 2018, 4:08:02 PM2/20/18
to jenkinsc...@googlegroups.com
Andrew Bayer resolved as Duplicate
Change By: Andrew Bayer
Status: Reopened Resolved
Resolution: Duplicate

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:24:41 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Duplicate
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages