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

Credentials support for git step

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • pipeline
    • None

      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

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

              Created:
              Updated:
              Resolved: