Using credentials from Jenkins store in a jenkinsfile

后端 未结 4 1857
轻奢々
轻奢々 2020-12-30 03:52

I made a multibranch pipeline project in Jenkins. I need to use two repositories and both need credentials.

I created a Jenkinsfile in repository1:

n         


        
4条回答
  •  星月不相逢
    2020-12-30 04:21

    I've had the exact same issue: checkout using credentials in a freestyle project works fine, checkout in a shell (as the jenkins user) works fine, and checkout in the pipeline fails. I've updated Jenkins + plugins to the latest version.

    I finally managed to get it to work by placing the correct key in /var/lib/jenkins/.ssh/id_rsa. It looks like the GitSCM plugin completely ignores the provided credentialsId, and just uses the key in /var/lib/jenkins/.ssh/id_rsa. I generated a keypair without passphrase for this.

    It is a workaround, and I suspect that GitSCM has a bug, but at least you can use the pipeline plugin.

提交回复
热议问题