[JIRA] (JENKINS-58515) parallel stage randomly fails with shared_libs calls

2 views
Skip to first unread message

clarsonneur@gmail.com (JIRA)

unread,
Jul 16, 2019, 8:36:05 AM7/16/19
to jenkinsc...@googlegroups.com
Christophe LARSONNEUR created an issue
 
Jenkins / Bug JENKINS-58515
parallel stage randomly fails with shared_libs calls
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2019-07-16 12:35
Environment: Jenkins core 2.176.1

blueocean-bitbucket-pipeline: 1.17.0
blueocean-git-pipeline: 1.17.0
blueocean-github-pipeline: 1.17.0
blueocean-pipeline-api-impl: 1.17.0
blueocean-pipeline-editor: 1.17.0
blueocean-pipeline-scm-api: 1.17.0
docker-workflow: 1.18
pipeline-build-step: 2.9
pipeline-githubnotify-step: 1.0.4
pipeline-graph-analysis: 1.10
pipeline-input-step: 2.10
pipeline-milestone-step: 1.3.1
pipeline-model-api: 1.3.9
pipeline-model-declarative-agent: 1.1.1
pipeline-model-definition: 1.3.9
pipeline-model-extensions: 1.3.9
pipeline-rest-api: 2.11
pipeline-stage-step: 2.3
pipeline-stage-tags-metadata: 1.3.9
pipeline-stage-view: 2.11
pipeline-utility-steps: 2.3.0
workflow-aggregator: 2.6
workflow-api: 2.35
workflow-basic-steps: 2.18
workflow-cps: 2.71
workflow-cps-global-lib: 2.13
workflow-durable-task-step: 2.32
workflow-job: 2.33
workflow-multibranch: 2.21
workflow-scm-step: 2.9
workflow-step-api: 2.20
workflow-support: 3.3

kernel: 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64
Priority: Critical Critical
Reporter: Christophe LARSONNEUR

Assume a shared_lib with following code:

 setup.groovy

def call(Map config) {
  path = config.get("ansible_path")
  project_name = config.get("project_name")

  sh label: "Copy playbook", script: "cp ${path}/${project_name}.yml ${env.HOME}/ansible-dev/."
  
 }

A Jenkinsfile with:

pipeline {
    agent any

    environment {
        ansible_path=".infra/ansible"
    }

    stages {
        stage('init') {
            steps {
                sh label: "cleanup", script: "rm -fr ${env.HOME}/ansible-dev ; mkdir -p ${env.HOME}/ansible-dev/environments/${environment}/${region}/"
            }
        }

        stage('deploy') {
            parallel {
                stage('bad-sunburst'){
                    environment {
                        project_name="hpgm-sunburst"
                    }

                    stages {
                        stage('ansible') {
                            steps {
                                echo "${project_name}"
                                setup project_name: "${project_name}", ansible_path: "${project_name}/${ansible_path}"

                                sh label: "test file", script: "ls -l ${env.HOME}/ansible-dev/${project_name}.yml"
                            }
                        }
                    }
                }

                stage('bad-screen-metrics'){
                    environment {
                        project_name="hpgm-screen-metrics"
                    }

                    stages {
                        stage('ansible') {
                            steps {
                                echo "${project_name}"
                                setup project_name: "${project_name}", ansible_path: "${project_name}/${ansible_path}"
                                sh label: "test file", script: "ls -l ${env.HOME}/ansible-dev/${project_name}.yml"
                            }
                        }
                    }
                }
                stage('good-segment'){
                    environment {
                        project_name="hpgm-segment"
                    }

                    stages {
                        stage('ansible') {
                            steps {
                                echo "${project_name}"
                                sh label: "Copy playbook", script: "cp ${project_name}/${ansible_path}/${project_name}.yml ${env.HOME}/ansible-dev/."

                                sh label: "test file 1", script: "ls -l ${env.HOME}/ansible-dev/${project_name}.yml"
                            }
                        }
                    }
                }
                stage('good-snapshot'){
                    environment {
                        project_name="hpgm-snapshot"
                    }

                    stages {
                        stage('ansible') {
                            steps {
                                echo "${project_name}"
                                sh label: "Copy playbook", script: "cp ${project_name}/${ansible_path}/${project_name}.yml ${env.HOME}/ansible-dev/."

                                sh label: "test file 1", script: "ls -l ${env.HOME}/ansible-dev/${project_name}.yml"
                            }
                        }
                    }
                }
            }
        }
    }
}

We assume source files to be there:

hpgm-snapshot/hpgm-snapshot.yml
hpgm-segment/hpgm-segment.yml
hpgm-screen-metrics/hpgm-screen-metrics.yml
hpgm-sunburst/hpgm-sunburst.yml

 

When we execute this pipeline we got errors, because expected filed copied are not copied when a run that from a shared_libs:

                     [Pipeline] sh (Copy playbook)
[good-segment]       + cp hpgm-segment/.infra/ansible/hpgm-segment.yml /var/lib/jenkins/ansible-dev/.
                     [Pipeline] sh (Copy playbook)
                     [Pipeline] sh (test file 1)
[good-snapshot]      + cp hpgm-snapshot/.infra/ansible/hpgm-snapshot.yml /var/lib/jenkins/ansible-dev/.
                     [Pipeline] sh (test file 1)
[bad-sunburst]       + cp hpgm-screen-metrics/.infra/ansible/hpgm-screen-metrics.yml /var/lib/jenkins/ansible-dev/.
                    [Pipeline] sh (Copy variables)
[bad-screen-metrics] + cp hpgm-screen-metrics/.infra/ansible/hpgm-screen-metrics.yml /var/lib/jenkins/ansible-dev/.
                    [Pipeline] sh (Copy variables)

 

 
When the pipeline use shared_libs in parallel, commands parameters are mixed.
When the pipeline use inline command, commands parameters are properly used.

Bad example:
[bad-sunburst] + cp hpgm-screen-metrics/.infra/ansible/hpgm-screen-metrics.yml /var/lib/jenkins/ansible-dev/. is wrong

It should be
 [bad-sunburst] + cp hpgm-sunburst/.infra/ansible/hpgm-screen-metrics.yml /var/lib/jenkins/ansible-dev/. is wrong

With online commands in Jenkinsfile, it looks good:

[good-*segment*] + cp hpgm-segment/.infra/ansible/hpgm-segment.yml /var/lib/jenkins/ansible-dev/.
[...]
[good-*snapshot*] + cp hpgm-snapshot/.infra/ansible/hpgm-snapshot.yml /var/lib/jenkins/ansible-dev/.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)
Reply all
Reply to author
Forward
0 new messages