1
votes

I have a jenkins pipeline which has two stage, two stage need clone code from code and parallel run different agent, how to share code in the stages?

stages {
    parallel("a":
    node('label1'){
     stage("Source"){
      git 'xxx'
     }
    }
   ,
   "b":node('label2'){
     stage("Source"){
      git 'xxx'
     }
    }
  }
}
1
well. it is as of now. July 17th 2020. I think the use of "Slave" is as of quite a few yesterdays not proper. I am going to label this question as "Requires Editing" such terms are now taboo when using such things.try Primary/Secondary.Lenn Dolling

1 Answers

0
votes

I think you are asking if you can get the two different agents to work on the same copy of the code in parallel, rather than them both checking out their own copy from git. Because the agents are actual different machines (or VMs etc), the only way I can think of to do this, is checking the code out on a networked file system that both agents mount.

But... this sounds like a bad idea. What if a is writing to a file and b is writing to the same file, who will win? You can't predict the order in which both are working through the source tree. You're likely to get unpredictable results.