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

CpsScmFlowDefinition does not resolve variables

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Component/s: workflow-cps-plugin
    • Labels:
    • Environment:
      Jenins 1.613, Workflow plugin 1.6
      Also: Jenkins 1.651.1, workflow-job 2.3
    • Similar Issues:

      Description

      When selecting the "Groovy CPS DSL from SCM" option for a worflow job, the SCM plugins do not appear to resolve build parameters or environment variables. I am using the git plugin and when I use it from other jobs I can specify a build parameter, like "BuildBranch", and use that when specifying what branch should be built:

      Branches to build: */${BuildBranch}

      This does not work when I use the Groovy CPS DSL from SCM.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Anna Tikhonova that sounds like an RFE for git-plugin not specific to Pipeline.

            Show
            jglick Jesse Glick added a comment - Anna Tikhonova that sounds like an RFE for git-plugin not specific to Pipeline.
            Hide
            asfaltboy Pavel Savshenko added a comment -

            Jesse Glick I came across this issue as well, and unchecking "lightweight checkout" also helped. However I cannot figure out why exactly, can you give a bit more context into why the env/parameter interpolation is disabled when LC is on ?

            Show
            asfaltboy Pavel Savshenko added a comment - Jesse Glick I came across this issue as well, and unchecking "lightweight checkout" also helped. However I cannot figure out why exactly, can you give a bit more context into why the env/parameter interpolation is disabled when LC is on ?
            Hide
            jglick Jesse Glick added a comment -

            Lightweight checkout is going through a completely unrelated code path, and currently SCMFileSystem implementations do not honor variables (or even have an API allowing them to honor variables IIRC). Would have to be a separate feature.

            Show
            jglick Jesse Glick added a comment - Lightweight checkout is going through a completely unrelated code path, and currently SCMFileSystem implementations do not honor variables (or even have an API allowing them to honor variables IIRC). Would have to be a separate feature.
            Hide
            mmallard Matthew Mallard added a comment -

            Has this "separate feature" been added yet to the "lightweight checkout" functionality? In my case, I have a pipeline job that is parameterized. One of the parameters is the branch name which I intend to use later on in the job when selecting the definition "Pipeline script from SCM". When selecting that you have the option to select your Git repository and Branches to build, but it doesn't recognize the parameter when "Lightweight checkout" is selected.

            Show
            mmallard Matthew Mallard added a comment - Has this "separate feature" been added yet to the "lightweight checkout" functionality? In my case, I have a pipeline job that is parameterized. One of the parameters is the branch name which I intend to use later on in the job when selecting the definition "Pipeline script from SCM". When selecting that you have the option to select your Git repository and Branches to build, but it doesn't recognize the parameter when "Lightweight checkout" is selected.
            Hide
            dschey Jürgen Wakunda added a comment -

            I have a jenkins installation which was set up in 2019. A job for building releases has a build parameter TAG_NAME. This variable is used as branch specifier

            refs/tags/${TAG_NAME}

            in the "Pipelinescript from SCM" git section and i have "lightweight checkout" activated. (it didn't work btw. telling me that it is falling back to full checkout)

             

            Until yesterday, it worked flawlessly, the variable was resolved correctly and the corresponding tag was checked out.

            Then i updated a bunch of plugins and restarted jenkins. Then the variable wasn't resolved any more. Only unchecking the "lighweight checkout" option helped.

            How could this have worked for me before if this problem is already so old?

            Started by upstream project "XXXXXXX" build number 200
            originally caused by:
             GitHub tag trigger
            hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- origin +refs/tags/${TAG_NAME}:refs/remotes/origin/${TAG_NAME}" returned status code 128:
            stdout: 
            stderr: fatal: Couldn't find remote ref refs/tags/${TAG_NAME}	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2436)
            	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2050)
            	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
            	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:572)
            	at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:364)
            	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
            	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
            	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115)
            	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69)
            	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309)
            	at hudson.model.ResourceController.execute(ResourceController.java:97)
            	at hudson.model.Executor.run(Executor.java:428)
            Finished: FAILURE
            

            Could it be that now with the updated plugins i would actually get a "lightweight" checkout and therefore the variable resolution doesn't work?

            Show
            dschey Jürgen Wakunda added a comment - I have a jenkins installation which was set up in 2019. A job for building releases has a build parameter TAG_NAME. This variable is used as branch specifier refs/tags/${TAG_NAME} in the "Pipelinescript from SCM" git section and i have "lightweight checkout" activated. (it didn't work btw. telling me that it is falling back to full checkout)   Until yesterday, it worked flawlessly, the variable was resolved correctly and the corresponding tag was checked out. Then i updated a bunch of plugins and restarted jenkins. Then the variable wasn't resolved any more. Only unchecking the "lighweight checkout" option helped. How could this have worked for me before if this problem is already so old? Started by upstream project "XXXXXXX" build number 200 originally caused by: GitHub tag trigger hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- origin +refs/tags/${TAG_NAME}:refs/remotes/origin/${TAG_NAME}" returned status code 128: stdout: stderr: fatal: Couldn't find remote ref refs/tags/${TAG_NAME} at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2436) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2050) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:572) at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:364) at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197) at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173) at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115) at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:428) Finished: FAILURE Could it be that now with the updated plugins i would actually get a "lightweight" checkout and therefore the variable resolution doesn't work?

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              nsnewland Nicholas Newland
              Votes:
              50 Vote for this issue
              Watchers:
              67 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: