指定属性一次,而不是两次

Geo*_*ler 1 jenkins jenkins-workflow jenkins-pipeline jenkins-2

当我在Jenkins 2多分支项目中有一个管道时,例如:

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}"
}
Run Code Online (Sandbox Code Playgroud)

我需要指定credentialsIdURL两次:

  1. 在上面的Jenkins文件中
  2. 在Jenkins UI中 在此输入图像描述

两次指定这两个属性似乎是多余的.是否有可能只指定一次

Krz*_*soń 5

您可以使用:

checkout scm
Run Code Online (Sandbox Code Playgroud)

而不是git命令,checkout scm将使用Jenkins配置中提供的数据.