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
What kind of credentials do you use?
I suggest that you use SSH credentials (i.e. private/public keys):
Then you need to use SSH URL as connection to your Git your credentials in your pipeline (instead of HTTP URL), as follows:
checkout([
$class: 'GitSCM', branches: [[name: '*/master']],
userRemoteConfigs: [[url:'ssh://BRNTZN@bitbucket.org:BRNTZN/repository2.git'],[credentialsId:'jenkins_ssh_key']]
])
Also, note that you might want to set a specific id for your credentials (e.g. jenkins_ssh_key
or BRNTZN_ssh_key
) to improve readability and simplify pipeline configuration.