Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins workspaces and concurrent builds, how do they work?

Tags:

jenkins

I am currently learning the ins and outs of Jenkins and Pipeline. One thing I do not yet understand is the following:

A Jenkins job by default can be executed concurrently (I can check the checkbox "Do not allow concurrent builds" if I don't want that).

What I don't understand is the following: Let say Jenkins checks out code in /var/lib/jenkins/workspace/my-project-workspace/

Now how would it be possible to run concurrent builds without conflicts? Let's say that build nr 1 checks out code in that path and starts testing it, and while doing that, build nr 2 is started and checks out code in that same path. How will that not conflict with build nr 1? I am probably missing something obvious here... Please help :)

like image 463
vrijdenker Avatar asked Jul 19 '17 16:07

vrijdenker


People also ask

How does Jenkins workspace work?

The workspace directory is where Jenkins builds your project: it contains the source code Jenkins checks out, plus any files generated by the build itself. This workspace is reused for each successive build.

What is concurrent builds in Jenkins?

Jenkins allows for parallel execution of builds for a Job. Job configuration page has a check box, "Execute concurrent builds if necessary". Also, in the master node configuration set the "# of executors" field to more than 1. Once these two are done, parallel job execution is enabled.

How do I create multiple workspaces in Jenkins?

Suppose your "development" Jenkins job workspace is /var/workspace/job1 . In the "code analysis" job configuration page, under the tab General click on Advanced... and select the option Use custom workspace and give the same workspace /var/workspace/job1 as of your "development" job.


1 Answers

The subdirectory inside the workspace/ folder will not always be your project name, but a (randomly) generated directory name. That's all the magic.

like image 169
StephenKing Avatar answered Sep 28 '22 01:09

StephenKing