[JIRA] (JENKINS-60529) SSH authentication fails during submodule checkout from declarative pipeline

11 views
Skip to first unread message

Simon.Richter@hogyros.de (JIRA)

unread,
Dec 18, 2019, 10:54:02 AM12/18/19
to jenkinsc...@googlegroups.com
Simon Richter created an issue
 
Jenkins / Bug JENKINS-60529
SSH authentication fails during submodule checkout from declarative pipeline
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-client-plugin, pipeline
Created: 2019-12-18 15:53
Priority: Major Major
Reporter: Simon Richter

Possibly similar to JENKINS-59546:

I have a project with a Jenkinsfile containing a declarative pipeline in a git repository that also has submodules. I have activated submodule processing, and submodules are initialized correctly, but cloning them fails with a login error from the ssh connection opened by git.

It seems that multiple keys are tried (I get two "Permission denied" messages), although credentials config inside the project explicitly specifies which key to use.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 18, 2019, 10:57:03 AM12/18/19
to jenkinsc...@googlegroups.com

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 18, 2019, 10:59:03 AM12/18/19
to jenkinsc...@googlegroups.com
Mark Waite commented on Bug JENKINS-60529
 
Re: SSH authentication fails during submodule checkout from declarative pipeline

Usually a configuration error in the submodule definition. For example, if the parent repository is cloned with ssh, then the submodule repository must be defined to use an ssh protocol URL to the submodule repository. Command line git needs the same protocol in the submodule as in the parent repo because it needs to use the same credentials.

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 18, 2019, 4:24:03 PM12/18/19
to jenkinsc...@googlegroups.com
Mark Waite resolved as Not A Defect
 
Change By: Mark Waite
Status: Open Resolved
Resolution: Not A Defect

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 18, 2019, 6:38:02 PM12/18/19
to jenkinsc...@googlegroups.com
 
Re: SSH authentication fails during submodule checkout from declarative pipeline

Here is the declarative Pipeline that I defined to test submodule cloning from a private repository. The private repository is referenced in 3 different multibranch jobs in my test environment. One of those test environments uses ssh protocol. The other two use https protocol. The declarative pipeline job skips all stages when it detects that the URL protocol is not ssh.

@Library('globalPipelineLibraryMarkEWaite') _

pipeline {
  agent {
    label '!windows && git-1.8+' // Older git versions don't do submodules well, use an sh step later, no windows
  }
  options {
    skipDefaultCheckout()
  }
  stages {
    stage('checkout') {
      when {
        // Only test when cloning from ssh protocol URL
        // Submodule is defined with ssh protocol URL
        expression { scm.userRemoteConfigs[0].url ==~ /g...@github.com:.*/ }
      }
      steps {
        deleteDir()
        checkout([$class: 'GitSCM',
                  branches: scm.branches,
                  userRemoteConfigs: scm.userRemoteConfigs,
                  extensions: [
                        [$class: 'SubmoduleOption', parentCredentials: true],
                        [$class: 'LocalBranch', localBranch: 'JENKINS-60529'],
                    ],
                  gitTool: 'Default' // JGit in git client plugin does not fully support submodules
        ])
      }
    }
    stage('build') {
      when {
        // Only test when cloning from ssh protocol URL
        // Submodule is defined with ssh protocol URL
        expression { scm.userRemoteConfigs[0].url ==~ /g...@github.com:.*/ }
      }
      steps {
        echo 'SCM url is ' + scm.userRemoteConfigs[0].url
        withAnt(installation: 'ant-latest', jdk: 'jdk8') {
          sh 'ant info'
        }
      }
    }
    stage('verify') {
      when {
        // Only test when cloning from ssh protocol URL
        // Submodule is defined with ssh protocol URL
        expression { scm.userRemoteConfigs[0].url ==~ /g...@github.com:.*/ }
      }
      steps {
        logContains([expectedRegEx: ".*Found:.*JENKINS-57936.*",
               failureMessage: "Missing submodule README contents."])
      }
    }
  }
}

Simon.Richter@hogyros.de (JIRA)

unread,
Dec 19, 2019, 7:44:02 AM12/19/19
to jenkinsc...@googlegroups.com

Ooooh, found it. "Use Credentials from default remote of parent repository" needs to be set. Sorry for the noise.

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 19, 2019, 8:13:12 AM12/19/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages