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

Credentials support for git step

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

      Internally we use gitlab as out git reposity server.
      Using a jenkins freestyle project and git plugin a checkout via git over ssh works fine using an ssh private key.

      In a workflow project I do not get a working checkout. This is the output I get:

      Starting...
      Running: Git
       > git rev-parse --is-inside-work-tree # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url git@git.local.domain:ps/project.git # timeout=10
      Fetching upstream changes from git@git.local.domain:ps/project.git
       > git --version # timeout=10
       > git fetch --tags --progress git@git.local.domain:ps/project.git +refs/heads/*:refs/remotes/origin/*
      ERROR: Error fetching remote repo 'origin'
      Running: Allocate node : Body : End
      Running: Allocate node : End
      Running: End of Workflow
      ERROR: Error fetching remote repo 'origin'
      Finished: FAILURE
      

      .. when using the following project:

      node('master'){
        echo "Starting..."
        git url: 'git@git.local.domain:ps/project.git', credentialsId:67c3072d-b9a7-44fa-a5aa-560ba9c1662f
      }
      

      I got the credentialsID from the working freestyle project.

      When enabling ssh debug-log on the (git/ssh)server side it seems that jenkins/workflow tries to establish the ssh connection without offering a key based authentication and the connection is closed by the client in the ssh preauth phase.

      I didn't get to manage to get debug output from the git-plugin when using the workflow plugin, but here is the exception I get from workflow:

      Dec 16, 2014 3:50:09 PM FINE org.jenkinsci.plugins.workflow.cps.CpsThread
      ran and produced error
      java.lang.reflect.UndeclaredThrowableException
              at org.jenkinsci.plugins.workflow.cps.CpsStepContext.replay(CpsStepContext.java:409)
              at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:164)
              at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:98)
              at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
              at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15)
              at WorkflowScript.run(WorkflowScript:4)
              at Unknown.Unknown(Unknown)
              at ___cps.transform___(Native Method)
              at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:69)
              at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:100)
              at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:76)
              at sun.reflect.GeneratedMethodAccessor258.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:606)
              at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
              at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
              at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
              at sun.reflect.GeneratedMethodAccessor116.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:606)
              at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
              at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
              at com.cloudbees.groovy.cps.Next.step(Next.java:58)
              at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:145)
              at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
              at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:267)
              at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:70)
              at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:176)
              at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:174)
              at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:111)
              at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: hudson.AbortException: Error fetching remote repo 'origin'
              at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:946)
              at hudson.plugins.git.GitSCM.checkout(GitSCM.java:972)
              at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:98)
              at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:70)
              at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution.start(AbstractSynchronousStepExecution.java:34)
              at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:137)
              at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:98)
              at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
              at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15)
              ... 30 more
      

      I'm using:
      Jenkins: 1.593
      Git-Plugin: 2.3.1
      Workflow-Plugin: 1.1

        Attachments

          Issue Links

            Activity

            ps Patrick Scharrenberg created issue -
            Hide
            jglick Jesse Glick added a comment -

            There is no credentialsId parameter for the git step. Currently if you need to pass credentials to a Git checkout, you must use the generic checkout step; the Snippet Generator is the easiest way to configure it.

            Show
            jglick Jesse Glick added a comment - There is no credentialsId parameter for the git step. Currently if you need to pass credentials to a Git checkout, you must use the generic checkout step; the Snippet Generator is the easiest way to configure it.
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Issue Type Bug [ 1 ] New Feature [ 2 ]
            Summary unable to git checkout via ssh key Credentials support for git step
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-26099 [ JENKINS-26099 ]
            Hide
            ps Patrick Scharrenberg added a comment -

            ok, my fault. Using the "general scm" step works fine using credentials.

            Show
            ps Patrick Scharrenberg added a comment - ok, my fault. Using the "general scm" step works fine using credentials.
            Hide
            jglick Jesse Glick added a comment -

            Right. Still, the git step is more convenient when writing flows without the generator. I wanted to avoid overloading it (and the svn step) with options, but credentialsId is so broadly needed that it makes sense to include.

            Show
            jglick Jesse Glick added a comment - Right. Still, the git step is more convenient when writing flows without the generator. I wanted to avoid overloading it (and the svn step) with options, but credentialsId is so broadly needed that it makes sense to include.
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 79 (Web Link)" [ 12148 ]
            jglick Jesse Glick made changes -
            Assignee Jesse Glick [ jglick ] Nicolas De Loof [ ndeloof ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Nicolas De Loof
            Path:
            scm-step/README.md
            scm-step/pom.xml
            scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java
            scm-step/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/GitStepTest.java
            http://jenkins-ci.org/commit/workflow-plugin/6838a3ce779d6645759e76456d39f1da95128d26
            Log:
            [FIXED JENKINS-26085] Credentials support for git step

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: scm-step/README.md scm-step/pom.xml scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java scm-step/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/GitStepTest.java http://jenkins-ci.org/commit/workflow-plugin/6838a3ce779d6645759e76456d39f1da95128d26 Log: [FIXED JENKINS-26085] Credentials support for git step
            scm_issue_link SCM/JIRA link daemon made changes -
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Resolved [ 5 ]
            Hide
            ahammar Anders Hammar added a comment -

            Only for git, not for svn? Why?

            Show
            ahammar Anders Hammar added a comment - Only for git, not for svn? Why?
            ahammar Anders Hammar made changes -
            Link This issue is related to JENKINS-27275 [ JENKINS-27275 ]
            jglick Jesse Glick made changes -
            Resolution Fixed [ 1 ]
            Status Resolved [ 5 ] Reopened [ 4 ]
            jglick Jesse Glick made changes -
            Status Reopened [ 4 ] Open [ 1 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            Hide
            jglick Jesse Glick added a comment -

            Anders Hammar JENKINS-27275 tracks the analogous change for the svn step.

            Show
            jglick Jesse Glick added a comment - Anders Hammar JENKINS-27275 tracks the analogous change for the svn step.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Nicolas De Loof
            Path:
            scm-step/README.md
            scm-step/pom.xml
            scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java
            scm-step/src/main/resources/org/jenkinsci/plugins/workflow/steps/scm/GitStep/config.jelly
            scm-step/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/GitStepTest.java
            http://jenkins-ci.org/commit/workflow-plugin/696119a41c8443c2d5099f7aba1f2e14cb7458b4
            Log:
            [FIXED JENKINS-26085] Credentials support for git step

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: scm-step/README.md scm-step/pom.xml scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java scm-step/src/main/resources/org/jenkinsci/plugins/workflow/steps/scm/GitStep/config.jelly scm-step/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/GitStepTest.java http://jenkins-ci.org/commit/workflow-plugin/696119a41c8443c2d5099f7aba1f2e14cb7458b4 Log: [FIXED JENKINS-26085] Credentials support for git step
            scm_issue_link SCM/JIRA link daemon made changes -
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Resolved [ 5 ]
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Nicolas De loof
            Path:
            scm-step/README.md
            scm-step/pom.xml
            scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java
            scm-step/src/main/resources/org/jenkinsci/plugins/workflow/steps/scm/GitStep/config.jelly
            scm-step/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/GitStepTest.java
            http://jenkins-ci.org/commit/workflow-plugin/eb0548c654af1df70b853d4194581a90b8f443ca
            Log:
            Merge pull request #79 from ndeloof/JENKINS-26085

            [FIXED JENKINS-26085] Credentials support for git step

            Compare: https://github.com/jenkinsci/workflow-plugin/compare/64be5ce6dd7b...eb0548c654af

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De loof Path: scm-step/README.md scm-step/pom.xml scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java scm-step/src/main/resources/org/jenkinsci/plugins/workflow/steps/scm/GitStep/config.jelly scm-step/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/GitStepTest.java http://jenkins-ci.org/commit/workflow-plugin/eb0548c654af1df70b853d4194581a90b8f443ca Log: Merge pull request #79 from ndeloof/ JENKINS-26085 [FIXED JENKINS-26085] Credentials support for git step Compare: https://github.com/jenkinsci/workflow-plugin/compare/64be5ce6dd7b...eb0548c654af
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            CHANGES.md
            http://jenkins-ci.org/commit/workflow-plugin/694a0f0ec1aba1fae0844654402329fbe7448647
            Log:
            JENKINS-26085 Noting merge of #79.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: CHANGES.md http://jenkins-ci.org/commit/workflow-plugin/694a0f0ec1aba1fae0844654402329fbe7448647 Log: JENKINS-26085 Noting merge of #79.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java
            http://jenkins-ci.org/commit/workflow-plugin/d22d9e6f11cb6550d4f11df148abf1608916d987
            Log:
            Merge pull request #99 from jglick/GitStep.credentialsId

            JENKINS-26085 Handle empty credentialsId

            Compare: https://github.com/jenkinsci/workflow-plugin/compare/52d1ebae8f46...d22d9e6f11cb

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java http://jenkins-ci.org/commit/workflow-plugin/d22d9e6f11cb6550d4f11df148abf1608916d987 Log: Merge pull request #99 from jglick/GitStep.credentialsId JENKINS-26085 Handle empty credentialsId Compare: https://github.com/jenkinsci/workflow-plugin/compare/52d1ebae8f46...d22d9e6f11cb
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Nicolas De Loof
            Path:
            scm-step/README.md
            scm-step/pom.xml
            scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java
            scm-step/src/main/resources/org/jenkinsci/plugins/workflow/steps/scm/GitStep/config.jelly
            scm-step/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/GitStepTest.java
            http://jenkins-ci.org/commit/workflow-scm-step-plugin/f7a7b2806011d4debd0c3074ac61a0ed673e3f42
            Log:
            [FIXED JENKINS-26085] Credentials support for git step

            Originally-Committed-As: 696119a41c8443c2d5099f7aba1f2e14cb7458b4

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: scm-step/README.md scm-step/pom.xml scm-step/src/main/java/org/jenkinsci/plugins/workflow/steps/scm/GitStep.java scm-step/src/main/resources/org/jenkinsci/plugins/workflow/steps/scm/GitStep/config.jelly scm-step/src/test/java/org/jenkinsci/plugins/workflow/steps/scm/GitStepTest.java http://jenkins-ci.org/commit/workflow-scm-step-plugin/f7a7b2806011d4debd0c3074ac61a0ed673e3f42 Log: [FIXED JENKINS-26085] Credentials support for git step Originally-Committed-As: 696119a41c8443c2d5099f7aba1f2e14cb7458b4
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 160075 ] JNJira + In-Review [ 196305 ]
            abayer Andrew Bayer made changes -
            Component/s pipeline-general [ 21692 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-plugin [ 18820 ]

              People

              Assignee:
              ndeloof Nicolas De Loof
              Reporter:
              ps Patrick Scharrenberg
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: