• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None

      Steps to reproduce

      1. Create a pipeline job
      2. Add a build parameter to specify the URL of a git repository, ${gitUrl}
      3. Add a build parameter to specify the build script to execute, ${script}
      4. Within the Pipeline section
        1. Select "Pipeline script from SCM"
        2. Select "Git" for the SCM
        3. Enter ${gitUrl} for the Repository URL
        4. Enter the branch to build
        5. Enter ${script} for the "Script Path"

      Perform a "Build with Parameters" and enter values for the gitUrl and script values and select Build.  The following error is reported

      Mar 16, 2017 2:43:53 PM org.jenkinsci.plugins.workflow.job.WorkflowRun finish
      INFO: Worker #4 completed: FAILURE
      Mar 16, 2017 2:43:53 PM org.jenkinsci.plugins.workflow.flow.FlowExecutionList unregister
      WARNING: Owner[Worker/4:Worker #4] was not in the list to begin with: []
      Mar 16, 2017 2:43:53 PM io.jenkins.blueocean.events.PipelineEventListener$1 run
      SEVERE: Unexpected error publishing pipeline FlowNode event.
      java.util.concurrent.ExecutionException: hudson.AbortException: /var/jenkins_home/workspace/Worker@script/${script} not found
      at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:289)
      at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276)
      at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:111)
      at io.jenkins.blueocean.events.PipelineEventListener$1.run(PipelineEventListener.java:226)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
      Caused by: hudson.AbortException: /var/jenkins_home/workspace/Worker@script/${script} not found
      at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:136)
      at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:59)
      at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:232)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:404)
      

      If ${script} is set to the location of a script, the job starts successfully.

          [JENKINS-42836] Build parameter not expanded in script path

          Joseph Lim added a comment - - edited

          @Benjamin - I have fork the workflow-cps source master branch and merge with the change done by Andrew Bayer.  I have committed the changes to my fork github  https://github.com/josephlim75/workflow-cps-plugin

          I've compiled successfully and produces the plugin hpi.  Tried it and it works

           

           

          Joseph Lim added a comment - - edited @Benjamin - I have fork the workflow-cps source master branch and merge with the change done by Andrew Bayer.  I have committed the changes to my fork github  https://github.com/josephlim75/workflow-cps-plugin I've compiled successfully and produces the plugin hpi.  Tried it and it works    

          Chris Broll added a comment -

          Any update on using variables from the environment in the Script file path?

          Chris Broll added a comment - Any update on using variables from the environment in the Script file path?

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java
          src/test/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinitionTest.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/2dc4bf82a1e095b09dde4638a50c893320432f93
          Log:
          [FIXED JENKINS-42836] env expand the script path from SCM.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java src/test/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinitionTest.java http://jenkins-ci.org/commit/workflow-cps-plugin/2dc4bf82a1e095b09dde4638a50c893320432f93 Log: [FIXED JENKINS-42836] env expand the script path from SCM.

          Andrew Bayer added a comment -

          Whoops, this was merged and released a while back, as of workflow-cps 2.49.

          Andrew Bayer added a comment - Whoops, this was merged and released a while back, as of workflow-cps 2.49.

          Fabian Holler added a comment -

          This does not work for me.

          I have the "Pipeline: Groovy" Plugin version 2.62 installed.
          Similiar to described in the ticket I do the following:

          • Configure my Pipeline job to have a string parameter called branch
          • In the "Pipeline script from SCM" section, I enter as branch specifier ${branch}
          • I start the job and as value for the branch parameter develop.

          The job fails during checkout with
          stderr: fatal: Couldn't find remote ref refs/heads/${branch}

          The variable is not dereferenced.

          Fabian Holler added a comment - This does not work for me. I have the "Pipeline: Groovy" Plugin version 2.62 installed. Similiar to described in the ticket I do the following: Configure my Pipeline job to have a string parameter called branch In the "Pipeline script from SCM" section, I enter as branch specifier ${branch } I start the job and as value for the branch parameter develop . The job fails during checkout with stderr: fatal: Couldn't find remote ref refs/heads/${branch } The variable is not dereferenced.

          Zishan Ahmad added a comment -

          fho abayer

          also a continued issue for me with "Pipeline: Groovy" plugin version 2.65

          can we get this reopened and fixed?

          Zishan Ahmad added a comment - fho abayer also a continued issue for me with "Pipeline: Groovy" plugin version 2.65 can we get this reopened and fixed?

          Jesse Glick added a comment -

          zishan a particular issue was identified and fixed, with test coverage. Please do not reopen. If you continue to have some issue which you believe is related, file a distinct issue report with complete, minimal steps to reproduce from scratch and link to this issue.

          Jesse Glick added a comment - zishan a particular issue was identified and fixed, with test coverage. Please do not reopen. If you continue to have some issue which you believe is related, file a distinct issue report with complete, minimal steps to reproduce from scratch and link to this issue.

          Fabian Holler added a comment - - edited

          It works only when 'lightweight checkout' is disabled.
          There is the ticket https://issues.jenkins-ci.org/browse/JENKINS-42971 for the issue.

          Fabian Holler added a comment - - edited It works only when 'lightweight checkout' is disabled. There is the ticket https://issues.jenkins-ci.org/browse/JENKINS-42971 for the issue.

          fho thanks a bunch. Was on a wild goose chase here trying to figure this out and was just about to file a ticket here when I saw your comment. Thanks! Once I disabled the lightweight checkout, all worked fine.

          Oliver Schneider added a comment - fho thanks a bunch. Was on a wild goose chase here trying to figure this out and was just about to file a ticket here when I saw your comment. Thanks! Once I disabled the lightweight checkout, all worked fine.

          ipleten added a comment - - edited

          It doesn't work anymore with or without 'lightweight checkout'.
          https://issues.jenkins-ci.org/browse/JENKINS-60250
          UPDATE: it might not work in some cases: see https://issues.jenkins-ci.org/browse/JENKINS-42971?focusedCommentId=370658&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-370658
          UPDATE2: it fails if readTrusted is used.

          ipleten added a comment - - edited It doesn't work anymore with or without 'lightweight checkout'. https://issues.jenkins-ci.org/browse/JENKINS-60250 UPDATE: it might not work in some cases: see https://issues.jenkins-ci.org/browse/JENKINS-42971?focusedCommentId=370658&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-370658 UPDATE2: it fails if readTrusted is used.

            abayer Andrew Bayer
            bkeyser_dgi Brian Keyser
            Votes:
            13 Vote for this issue
            Watchers:
            26 Start watching this issue

              Created:
              Updated:
              Resolved: