并行管道DSL:由于并行,作业细节之间(下游)混合

时间:2019-06-23 12:24:43

标签: jenkins jenkins-pipeline jenkins-groovy

当我们运行pipline DSL作业时,有时会遇到并行某些作业包含错误细节的情况,例如,可能是由于并行执行而导致的artifcats插件URL错误,

当我们在同一点“阶段”上并行运行时,通常当我们运行约100个作业时,作业的详细信息有时无法正确地映射并与其他作业混合在一起

在一个阶段中,我定义了一系列任务,包括构建作业>> v2_Core_Task_Runner_Slack(downStream),copyAtrifcate和报告,最后我们使用并行任务命令并行运行它,但是有时作业与其他作业混合(pJob参数),请参见下面的代码

stage ("Run Tests") {

        steps {

            script {

                tasks = [:]
                products_set = [].toSet()

                features_list.each {

                    def featureName = it.key

                    tasks[featureName] = {

                        withEnv(["FEATURE_NAME=${featureName}"]) {


                            def valArr = it.value.split(",")
                            def productName = valArr[0]
                            def productPath = valArr[1]


                                println "Run test startTime : " + metaData["tests"][it.key]['phases']['Run Tests']["startTime"]

                            println "Calling build for feature '${featureName}' in job '${productName}'"
                            pJob = build job: "v2_Core_Task_Runner_Slack", propagate: false, parameters: [
                                [$class: 'StringParameterValue', name: 'FeatureName', value: "${featureName}"],
                                [$class: 'StringParameterValue', name: 'FeaturePath', value: "${productPath}"],
                                [$class: 'StringParameterValue', name: 'TagName', value: "${params.TagName}"],
                                [$class: 'StringParameterValue', name: 'Environment', value: "${params.Environment}"],
                                [$class: 'BooleanParameterValue', name: 'CreateTenant', value: params.CreateTenant],
                                [$class: 'StringParameterValue', name: 'TagNameCondition', value: "${params.TagNameCondition}"],
                                [$class: 'StringParameterValue', name: 'TenantTemplate', value: "${params.TenantTemplate}"],
                                [$class: 'StringParameterValue', name: 'ClientLabel', value: "${params.ClientLabel}"],
                                [$class: 'StringParameterValue', name: 'SlackChannel', value: "${params.SlackChannel}"]
                            ]
                            metaData["tests"][it.key]['phases']['Run Tests']["endTime"] = getEpochTime();
                            metaData["tests"][it.key]['consoleUrl'] = pJob.getAbsoluteUrl();
                            metaData["tests"][it.key]['result'] = pJob.getResult();

                            println "Job result = " + pJob.getResult() + ", Url: " + pJob.getAbsoluteUrl()

                            println "Copy artificats to 'allreports/${productName}/${featureName}'"

                            copyArtifacts(
                                projectName: 'v2_Core_Task_Runner_Slack',
                                filter: '**/report.json',
                                fingerprintArtifacts: true,
                                target: "allreports/${productName}/${featureName}",
                                flatten: true,
                                selector: specific(pJob.getId()),
                                optional: true
                            )



                            products_set.add(productName)

                        }
                    }
                }

                parallel tasks
                metaData["endTime"] = getEpochTime()
                metDataStr = new JsonBuilder(metaData).toPrettyString()
            }

}

}

see problem below in LOGS: same URLs (1576 X 2) are pointing to the same runner job path, issues with parallelization 

*[CreateDeleteObjectHistory] Job result = SUCCESS, Url: http://TestServerJenkins_Auto1:8080/job/v2_Core_Task_Runner_Slack/1576/
[Pipeline] [CreateDeleteObjectHistory] echo
[CreateDeleteObjectHistory] Copy artificats to 'allreports/MobileNative/CreateDeleteObjectHistory'
[Pipeline] [CreateDeleteObjectHistory] step
[CreateDeleteObjectHistory] Copied 1 artifact from "v2_Core_Task_Runner_Slack" build number 1576
[Pipeline] [Sanity-RightClickSchedule] echo
[Sanity-RightClickSchedule] 20190617-13:16:05.697
[Pipeline] [Sanity-RightClickSchedule] echo
[Sanity-RightClickSchedule] Job result = SUCCESS, Url: http://TestServerJenkins_Auto1:8080/job/v2_Core_Task_Runner_Slack/1576/
[Pipeline] [Sanity-RightClickSchedule] echo
[Sanity-RightClickSchedule] Copy artificats to 'allreports/Sanity/Sanity-RightClickSchedule'
[Pipeline] [Sanity-RightClickSchedule] step
[Sanity-RightClickSchedule] Copied 1 artifact from "v2_Core_Task_Runner_Slack" build number 1576
[Pipeline] [Sanity-ScheduleUpdate] readFile*

0 个答案:

没有答案