Jenkins groovy 管道 - git 结帐错误

Jenkins groovy pipeline - git checkout error

我已经使用 Groovy DSL 定义了一个简单的 Jenkins 管道。我的意图是它只会检查我的 git 存储库。但是我收到一个错误。

根据我的 groovy DSL 定义:

stage 'build'
node 
{
    git branch: '*/mybranch', credentialsId: 'my credentials', url: 'git@git.servername:pathto/myrepo.git'
}

我期待 Jenkins 管道简单地检查我的 git 存储库。

但是我收到以下错误:

ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE

谁能帮我解决这个问题?

更详细的版本有效:

checkout([$class: 'GitSCM', branches: [[name: '*/mybranch']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'myCredentials', url: 'git@git.servername:pathto/myrepo.git']]])

不过最好使用简写版本。

分支说明符上没有 */ 对我有用。

试试这个:

git branch: 'mybranch', credentialsId: 'my credentials', url: 'git@git.servername:pathto/myrepo.git'