When I have a pipeline in Jenkins 2 multi-branch project like :
node {
stage 'Stage Checkout'
// Checkout code from repository and update any submodules
//checkout scm
git credentialsId: 'myId', url: 'https://gitlab.mycompany.com'
stage 'Stage Build'
echo "My branch is: ${env.BRANCH_NAME}"
}
I do need to specify the credentialsId
and URL
twice:
It seems to be redundant to specify these two properties twice. Is there a possibility to specify them only once?
You can use:
checkout scm
Instead of git
command, checkout scm
will use the data provided in the Jenkins configuration.