参数未传递给jenkins parallel build

时间:2018-06-01 14:39:11

标签: jenkins groovy jenkins-plugins jenkins-pipeline

我有一个管道作业,我试图使用Jenkins Groovy并行运行两个buildnode上的ansible playbooks。我只需要在prod期间执行第二个块。

stage ("Ansible Deploy") 
    {   
        parallel (
        'master' : {    
            stage ('Ansible Deploy on master server')
            {
                dir('ansible')
                {
                echo "$playbook"
                echo "$inventory"
                echo "$ansibleVersion"
                }
            }
        },
        'node2' : { 
            if(environment == 'prod') {
                node("$buildAgent2") 
                { 
                 stage ('Ansible Deploy on node2')
                    {
                    dir('ansible')
                    {
                    echo "$playbook"
                    echo "$inventory"
                    echo "$ansibleVersion"
                    }
                    }
                } 
                    } else  {
                            echo 'Skipping this block, as it only applicable for prod'
                            }
            }
       )
}

这是我在控制台上获得的输出,我没有看到在并行块中传递给node2的构建参数。

基于运行的输出

[Pipeline] stage   
[Pipeline] { (Ansible DB Deploy)   
[Pipeline] parallel   
[Pipeline] [master] { (Branch: master)   
[Pipeline] [otp.us.prod2] { (Branch: node2)   
[Pipeline] [master] stage   
[Pipeline] [node2] node   
20:18:18 [node2] Running on node2 in /appserver/workspace/TEST-PROD/Test_Deploy_Database   
[Pipeline] [master] deleteDir   
[Pipeline] [node2] {   
[Pipeline] [node2] stage   
[Pipeline] [node2] { (Ansible Deploy on node2)   
[Pipeline] [node2] }   
[Pipeline] [node2] // stage   
[Pipeline] [node2] }   
[Pipeline] [node2] // node   
[Pipeline] [node2] }   
20:18:18 [node2] Failed in branch node2   

[Pipeline] [master] // stage   
[Pipeline] [master] stage   
[Pipeline] [master] { (Ansible Deploy on Master or build server)   
[Pipeline] [master] dir   
20:18:30 [master] Running in /appserver/workspace/TEST-PROD/Test_Deploy_Database   
[Pipeline] [master] {    
[Pipeline] [master] echo    
20:18:30 [master] testdeployDbRelease.yml   
[Pipeline] [master] echo    
20:18:30 [master] inventory/testprod    
[Pipeline] [master] echo    
20:18:30 [master] ansible2.4.2.0  

谢谢和问候 圣

0 个答案:

没有答案