Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47103

Parallel stages in declarative pipelines don't work with docker agents

      If you have a Jenkinsfile with a top-level agent { docker {}} section you and use parallel {} around nested stages, all the stages will run on the same slave, at the same time (even if the slave has only one executor).

      If you add agent { docker {}} to each stage, they will run on other slaves, but docker run will only be invoked once, for the top-level and never again. Docker stop will run for all stages though.

      If you remove the top-level agent { docker {}} and only leave it in stages, docker run will never be invoked.

          [JENKINS-47103] Parallel stages in declarative pipelines don't work with docker agents

          Also, having to copy-paste the agent { docker {}} section in all stages is unexpected and would generate a lot of copy-pasta. For me, that's 13 lines of code. I don't want that redundancy.

          wknapik wknapik added a comment - Also, having to copy-paste the agent { docker {}} section in all stages is unexpected and would generate a lot of copy-pasta. For me, that's 13 lines of code. I don't want that redundancy.

          Andrew Bayer added a comment -

          So the first case you described is exactly what would be expected - if you don't specify an agent on a stage, whether it's parallel or not, it's going to run in the top level agent. The second case sounds like JENKINS-46831.

          Andrew Bayer added a comment - So the first case you described is exactly what would be expected - if you don't specify an agent on a stage , whether it's parallel or not, it's going to run in the top level agent . The second case sounds like JENKINS-46831 .

          Andrew Bayer added a comment -

          Closing this as a dupe of JENKINS-46831, since the main problem here (that you can't do a different docker agent in stages if you've got a docker agent defined at the top level) is the same whether we're talking about parallel or non-parallel stages.

          Andrew Bayer added a comment - Closing this as a dupe of JENKINS-46831 , since the main problem here (that you can't do a different docker agent in stages if you've got a docker agent defined at the top level) is the same whether we're talking about parallel or non-parallel stages.

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            abayer Andrew Bayer
            wknapik wknapik wknapik
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: