-
Bug
-
Resolution: Not A Defect
-
Blocker
-
None
-
Jenkins on premise - ver. 2.175,
Checked with Jenkins stabe 2.164.2 - same issue
RH 7.6 server
Latest version of all plugins [groovy, pipeline, declarative pipeline etc]
When running declarative pipeline with two maps and using function something got mixed.
example code:
pipeline{ agent { node 'builder_linux_1' } stages{ stage('test'){ steps{ script{ first_map = [:] first_map['JIRA-1'] = ['ArtifactId':'first_ART-1','ArtifactVersion':'1.0.3-1','ParentIssue':'JIRA-0'] first_map['JIRA-2'] = ['ArtifactId':'first_ART-2','ArtifactVersion':'1.0.3-1','ParentIssue':'JIRA-0'] second_map = [:] second_map['JIRA-12'] = ['ArtifactId':'second_ARTIFACT-100','ArtifactVersion':'1.0.3-10','ParentIssue':'JIRA-0'] def ParallelSteps = [:] ParallelSteps['first'] = { test(first_map, 'FIRST') } ParallelSteps['second'] = { test(second_map, 'SECOND') } parallel ParallelSteps } } } } } void test(ARTIFACT_MAP, TECH){ ARTIFACT_MAP.each { art -> if (TECH == 'SECOND'){ splited_artifact_name = art.value['ArtifactId'].tokenize('_') splited_artifact_name.remove(splited_artifact_name[0]) TEMP_HOLDER_ARTIFACT_ID = splited_artifact_name.join('_') } else { TEMP_HOLDER_ARTIFACT_ID = art.value['ArtifactId'] } dir(TECH){ println "${TEMP_HOLDER_ARTIFACT_ID}, ${TECH}" } } }
The output is:
[Pipeline] stage [Pipeline] { (test) [Pipeline] script [Pipeline] { [Pipeline] parallel [Pipeline] { (Branch: first) [Pipeline] { (Branch: second) [Pipeline] dir Running in /home/devops/.jenkins/workspace/test_15/FIRST [Pipeline] { [Pipeline] dir Running in /home/devops/.jenkins/workspace/test_15/SECOND [Pipeline] { [Pipeline] echo ARTIFACT-100, FIRST [Pipeline] } [Pipeline] echo ARTIFACT-100, SECOND [Pipeline] } [Pipeline] // dir [Pipeline] // dir [Pipeline] } [Pipeline] dir Running in /home/devops/.jenkins/workspace/test_15/FIRST [Pipeline] { [Pipeline] echo first_ART-2, FIRST [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // parallel [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline
Now if in the mention pipeline i will remove the 'dir' function from the void function
dir(TECH){ println "${TEMP_HOLDER_ARTIFACT_ID}, ${TECH}" }
and just print:
println "${TEMP_HOLDER_ARTIFACT_ID}, ${TECH}"
everything looks fine....
[Pipeline] { (Branch: first) [Pipeline] { (Branch: second) [Pipeline] echo first_ART-1, FIRST [Pipeline] echo ARTIFACT-100, SECOND [Pipeline] } [Pipeline] echo first_ART-2, FIRST
found that it's work well if running the 'if statement' inside the dir func..
void test(ARTIFACT_MAP, TECH){ ARTIFACT_MAP.each { art -> dir(TECH){ if (TECH == 'SECOND'){ splited_artifact_name = art.value['ArtifactId'].tokenize('_') splited_artifact_name.remove(splited_artifact_name[0]) TEMP_HOLDER_ARTIFACT_ID = splited_artifact_name.join('_') } else { TEMP_HOLDER_ARTIFACT_ID = art.value['ArtifactId'] } println "${TEMP_HOLDER_ARTIFACT_ID}, ${TECH}" } } }
NOT WORKING IF TAKING THE PRINTLN OUTSIDE 'DIR()'