有人可以帮我将下面的 Jenkins 脚本管道转换为声明性管道吗
node('agent') {
if ( ! "${GIT_BRANCH}".isEmpty()) {
branch="${GIT_BRANCH}"
} else {
echo 'The git branch is not provided, exiting..'
sh 'exit 1'
}
version = extract_version("${GIT_BRANCH}")
if ( "${GIT_BRANCH}".contains("feature")) {
currentBuild.displayName = "${version}-SNAPSHOT-${env.BUILD_ID}"
}
else {
currentBuild.displayName = "${version}-${env.BUILD_ID}"
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试检查是否提供了 git branch 并根据 git branch 动态设置 jenkins build id