Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 在管道作业中指定分支_Git_Jenkins_Jenkins Pipeline - Fatal编程技术网

Git 在管道作业中指定分支

Git 在管道作业中指定分支,git,jenkins,jenkins-pipeline,Git,Jenkins,Jenkins Pipeline,我们可以读取参数值并在管道作业的分支说明符中使用它吗。需要将git分支指定为参数,并在管道作业中使用相同的分支说明符 假设您的参数名为gitBranch,那么您可以这样添加它: checkout([$class: 'GitSCM', branches: [[name: params.gitBranch]] ..) 假设您的参数名为gitBranch,那么您可以这样添加它: checkout([$class: 'GitSCM', branch

我们可以读取参数值并在管道作业的分支说明符中使用它吗。需要将git分支指定为参数,并在管道作业中使用相同的分支说明符

假设您的参数名为
gitBranch
,那么您可以这样添加它:

checkout([$class: 'GitSCM',
         branches: [[name: params.gitBranch]]
         ..)

假设您的参数名为
gitBranch
,那么您可以这样添加它:

checkout([$class: 'GitSCM',
         branches: [[name: params.gitBranch]]
         ..)

我在groovy中编写了以下代码,以提取我的多管道文件中的当前分支:

git branch: env.BRANCH_NAME, credentialsId: '[credential string]', url: 'git@github.com:[user]/[repo].git'

“帮助”将向您显示正确的凭据字符串和url。

我在groovy中编写了以下内容,以在我的多管道文件中提取当前分支:

git branch: env.BRANCH_NAME, credentialsId: '[credential string]', url: 'git@github.com:[user]/[repo].git'

“帮助”将向您显示正确的凭据字符串和url。

我需要试试这个。您提到的是管道工程还是多分支管道工程,但它也应该适用于多分支管道。我尝试过这个,但我得到了一个错误,即
groovy.lang.MissingPropertyException:没有这样的属性:git for class:groovy.lang.Binding
您试图执行的确切代码是什么?我这是一个愚蠢的错误。我没有添加参数。在变量名之前。我需要试试这个。您提到的是管道工程还是多分支管道工程,但它也应该适用于多分支管道。我尝试过这个,但我得到了一个错误,即
groovy.lang.MissingPropertyException:没有这样的属性:git for class:groovy.lang.Binding
您试图执行的确切代码是什么?我这是一个愚蠢的错误。我没有添加参数。在变量名之前。