我有一个父级工作,内部称为几个子级工作。首先创建一个作业(导入库内容),然后在第一个作业导入库内容后并行运行下三个作业。因此,我的第一个作业按顺序运行并发布,其他三个作业并行运行。 我想将参数从父作业传递到所有子作业。但是,我无法这样做。我正在使用“ currentBuild.rawBuild.getAction(ParametersAction).getParameters()”将参数推送到子作业,但是,我无法这样做。更令人沮丧的是,我无法找到根本原因。您能帮我吗?请在下面找到我的代码:
@Library('JenkinsLibrary') _
properties(
[
[
$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '5']
],
parameters([
string(defaultValue: "jack", description: '', name: 'Username'),
string(defaultValue: "jacknjill", description: '', name: 'Password'),
])
]
)
def myparams = currentBuild.rawBuild.getAction(ParametersAction).getParameters()
pipeline{
agent <some label name>
stages {
stage('Run Tests for content_import'){
steps{
script{
echo "Running Test for content_import"
build job: 'content_import', parameters: myparams, propagate: true, wait: true
}
}
}
stage('Run PARALLEL TESTS'){
parallel {
stage('Run FIRST_TEST'){
steps{
script{
echo "Running Test for FIRST_TEST"
build job: 'FIRST_TEST', parameters: myparams, propagate: true, wait: true
}
}
}
stage('Run SECOND_TEST'){
steps{
script{
echo "Running Test for SECOND_TEST"
build job: "SECOND_TEST", parameters: myparams, propagate: true, wait: true
}
}
}
stage('Run THIRD_TEST'){
steps{
script{
echo "Running Test for THIRD_TEST"
build job: "THIRD_TEST", parameters: myparams, propagate: true, wait: true
}
}
}
}
// failFast: true
}
}
}