我有一个在Linux节点上执行的管道作业。它检查开发的HEAD并完成任务。然后,它将调用要在Windows框上执行的自由式作业。我想确保自由样式作业使用管道作业正在使用的相同GIT_COMMIT哈希结束。我的想法是将参数(COMMIT)定义为$ {GIT_COMMIT}的值。我要传递的其他参数似乎工作正常。
以下是我尝试失败的代码块:
def BRANCH_NAME = "develop"
def SW_VERS_PREFIX = "${BRANCH_NAME}_BUILD"
def TS = new Date()
def TS_FORMATTED = TS.format("yyyyMMddHHmmss")
def SW_VERS = "2.2.6.0.${TS_FORMATTED}"
def COMMIT = ""
pipeline {
agent {
node {
label 'centosdevbox'
}
}
stages {
stage ('Checkout develop branch') {
steps {
git branch: "develop",
credentialsId: 'builder',
url: 'ssh://git@fqdn:7999/proj/repo.git'
}
}
stage ('Build Freestyle Job Test') {
steps {
build job: 'param_pass_test', parameters: [
string (name: "BRANCH_NAME", value: "${BRANCH_NAME}"),
string (name: "SW_VERS_PREFIX", value: "${SW_VERS_PREFIX}"),
string (name: "SW_VERS", value: "${SW_VERS}"),
string (name: "COMMIT", value: "${env.GIT_COMMIT}")]
}
}
}
}