由于env变量仅适用于Multibranch-build,因此我正在使用Jenkinsfile。我需要获取CHANGE_TARGET
属性,以便可以预先合并请求,然后进行构建。我已经检查了env变量的完整列表,但是没有什么有用的。
如何通过Multibranchpipline,Gitlab和Jenkinsfile获得以下属性?
CHANGE_ID
For a multibranch project corresponding to some kind of change request, this will be set to the change ID, such as a pull request number, if supported; else unset.
CHANGE_URL
For a multibranch project corresponding to some kind of change request, this will be set to the change URL, if supported; else unset.
CHANGE_TITLE
For a multibranch project corresponding to some kind of change request, this will be set to the title of the change, if supported; else unset.
CHANGE_AUTHOR
For a multibranch project corresponding to some kind of change request, this will be set to the username of the author of the proposed change, if supported; else unset.
CHANGE_AUTHOR_DISPLAY_NAME
For a multibranch project corresponding to some kind of change request, this will be set to the human name of the author, if supported; else unset.
CHANGE_AUTHOR_EMAIL
For a multibranch project corresponding to some kind of change request, this will be set to the email address of the author, if supported; else unset.
CHANGE_TARGET
For a multibranch project corresponding to some kind of change request, this will be set to the target or base branch to which the change could be merged, if supported; else unset.
答案 0 :(得分:1)
您可以将Gitlab变量用于合并请求构建 gitlabSourceBranch 和 gitlabTargetBranch ,要进行预构建合并,可以使用以下签出代码:-
checkout(
[$class: 'GitSCM', branches: [[name: 'origin/${gitlabSourceBranch}']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'PreBuildMerge', options: [fastForwardMode: 'FF', mergeRemote: 'origin', mergeTarget: '${gitlabTargetBranch}']],
[$class: 'UserIdentity', email: 'abc@mail.com', name: 'user'],
[$class: 'RelativeTargetDirectory', relativeTargetDir: "C:\Test\Merge" ]], submoduleCfg: [],
userRemoteConfigs: [ [credentialsId: 'user', name: 'origin', url: "${gitlabTargetRepoHttpUrl}"] ]
])
有关更多信息,请关注this