1
votes

Suppose that I have one jenkins node with one executor and I have to run i.e. tests and build stages in parallel.

node("jenkinsNodeWithOneExecutor") {

    parallel {
        test: {echo "run test" ... }
        build: {echo "run build" ...}
    }

}

How this will work? In the logs I see that that it runs parallel. Is it possible? I thought that every parallel task needs own executor...

PS. When trying to run job twice: Waiting for next available executor on ...

1

1 Answers

2
votes

When you run a job in parallel the job will branch off and create two different jobs which will (ideally) execute simultaneously.

In your example you'd actually have three jobs: the original job, the "test" job, and the "build" job. You would need three executors available to process the script in parallel. If you're running the initial job on the same node you're trying to run parallel jobs on and you only have one executor this job would always hang indefinitely waiting for an executor that will never be available. If you're running the original job on another node it'd process your jobs sequentially since you only have one executor.

Are you sure you want to run your tests in parallel with your build? Typically tests have a dependency on whatever you've built. This would run the tests at the same time as the build and your build artifacts may not be available yet.