1

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:

  1. in the Jenkinsfile like above
  2. in the Jenkins UI enter image description here

It seems to be redundant to specify these two properties twice. Is there a possibility to specify them only once?

Rob
  • 14,746
  • 28
  • 47
  • 65
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292

1 Answers1

5

You can use:

checkout scm

Instead of git command, checkout scm will use the data provided in the Jenkins configuration.

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115