Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Jenkins, how do I set SCM behavior for the master node rather the build nodes?

I'm aware I'm lacking basic Jenkins concepts but with my current knowledge it's hard for to research successfully - maybe you can give me some hints I can use to re-word my question if needed.

Currently I'm facing a situation in which in a setup with several build nodes the Jenkins master machine is running out of disk space because Jenkins clones git repositories on both, the master and build nodes (and the master only has limited space). This question explains why.

Note: the master node itself does not build anything - it just clones the repo to a local workspace folder (I guess it just needs the Jenkinsfiles).

Going through the job configurations and googling this issue I find options regarding shallow and sparse clones or cleaning up the workspace before or after the build using the Cleanup Plugin. But those settings and plugins only care about the checkout done with checkout(SCM) on the build nodes, not the master.

But in case I want to leave the situation as is on the build nodes but keep the workspace folders on the Jenkins master machine slim, how do I approach this? What do I have to search for?

And as a side question - isn't it possible to have something like "git exports"? I.e. having the .git folders removed after checking out the commit I need?

In case it depends on the kind of job I use, I'm using scripted pipeline jobs.

like image 289
frans Avatar asked Nov 03 '21 07:11

frans


People also ask

Can we use different nodes for each stage in Jenkins?

You can also mix and match node { stage {..}} and stage { node {..}} within your pipeline codes. By design (in Jenkins, as well as in the concept of continuous delivery), stages do not execute in parallel. Only the steps within a single stage are executed in parallel.

How do you restrict Jenkins job to execute on a particular node?

Use Authorize Project plugin to assign authentication to your builds. Then Just set Computer/Build permissions for you nodes (Can be done in Role Strategy plugin for example) Use Job Restrictions Plugin to restrict access to node via Node properties.

How does Jenkins choose a node?

By default, Jenkins employs the algorithm known as consistent hashing to make this decision. More specifically, it hashes the name of the node, in numbers proportional to the number of available executors, then hashes the job name to create a probe point for the consistent hash.


1 Answers

I've got a similar setup: A master node, multiple build nodes.

Simply, I set the number of executors=0 on the master node (from Manage Jenkins -> Manage Nodes), so every job will land on build nodes.

The only repo cloned on the master is the shared library.

like image 175
Marco Caberletti Avatar answered Oct 21 '22 05:10

Marco Caberletti