In part of our testing setup we are build our artifacts needed and then copying a template job and settings its name so it recognizable.
Build artifact -> copy test template -> ending with a job for each
test case
that means i'm ending up with lots of jobs with Test_Client${BRANCHNAME}_Server${BRANCHNAME}
I'm running through these jobs alot while testing that branch, but as soon as it's merged it's not going to be touched again, which is why i would like to create a job of sorts that simply deletes the jobs that havn't been run for the 14 days or so.
Does anyone know a way of doing this? and not just cleaning out the workspace.
Thanks!
It may be a big change, but this is an ideal case for the Multibranch pipeline.
On one project, we have a master branch and version branches. The developers branch to short-lived feature branches or other branching purposes. As the branches are created and pushed to github, the multibranch job picks them up and starts building them. Developers get quick feedback that the changes will pass the build. When they merge them to master or to a version branch, then delete the branch, the multibranch job goes away.
Related
I currently have a multibranch pipeline on Jenkins which rebuilds all of the open PRs (and aborts the running builds) when a commit is pushed to master (i.e. when a branch is merged).
However, I have an optional stage which allows me to run some tests in the PRs. These tests can take up to several hours(!)
Ideally, once a commit is pushed to master, I would like to wait for these optional tests on the PRs to be over before rebuilding all of the PRs, in order not to abort them.
At first, I thought of a read-write lock using temporary files on my workspace. However, this won't work since the PRs are rebuilded before entering the Jenkinsfile.
The best I could find was the "Ignore rebuilding merge branches when only the target branch changed" option from Basic Branch Build Strategies but this simply prevents the rebuilds, instead of delaying them.
Do you have any ideas about a possible workaround for this? Any help would be greatly appreciated.
I am facing an issue where I notice in my organisation sometimes engineers make changes to the Jenkins file and they change the Jenkins job branch inside the Branch Specifier (blank for 'any') section. Now, the issue is engineers sometimes forget to merge their changes from their dedicated branch to the stable branches such as the master branch for example.
I want to track all those Jenkins Jobs and send it an alert on Slack if the Jenkins Jobs are running from non-master branches. It will help me and my team to trace out easily the jobs which are not running from the master branch.
Sending alerts via Slack is easy, I am more interested in tracing the non-master branches.
Basically you want to receive an alarm if Jenkins is building a branch other than 'master'?
Since editing Jenkinsfile does not make sense (as your developers can change the file to their taste), you need to think of something else. One of my thoughts was to make Jenkins run on Jenkinsfile2 which would send your alarm and then just build Jenkinsfile. But that is not fully thought through (I guess this is not a full match: How to invoke a jenkins pipeline A in another jenkins pipeline B)
Another, easier to implement option could be to have another Jenkins job monitoring the same repository. It runs a pipeline directly coded in Jenkins that just checks the branch name and sends the alarm if need be. The branch name should be available
I've set up multibranch pipeline to track my repo and automatically build and test for all merge requests. It works wonders, however, I noticed that Jenkins creates a new workspace for each new branch. It is a pretty big project with a heavy build process and a lot of non-tracked cache files, that mostly stay valid from one version to another - so if instead of a fresh git checkout it would re-use previous workspace, it would build much faster (and also not use up so much hard drive space).
How can I configure it to re-use the same workspace for different branches?
After researching the issue, I found out that this is not something I can do with multibranch pipeline, so I switched to using the regular pipeline project. Now every build uses one of the available workspaces, so they end up re-using previous workspaces and the same cache files that really speed up the build.
Jenkins for MultiBranch projects by default uses isolated workspaces for every branch.
Jobs within the same branch use the same workspace.
A possible solution for you is to use ws(path) inside a pipeline.
node("agent_name") {
ws(workspacePath) {
echo '...'
// ..
}
}
Is the anyway to make a Jenkins Multibranch Pipeline better support incremental builds by preferring the last build node when it build a branch instead of choosing an available node more or less randomly?
Details:
We are setting up a Jenkins multibranch pipeline for a large Git project, where we use Make to build and test a lot of code. A full build takes 6-8 hours, but the dependency tracking in Make is good enough for us to use incremental builds, shortening most our build times a lot. For this to work, Jenkins have to pick the same workspace for changes to the same branch again. Luckily it does so - but only on the same build node.
We have some identical Jenkins slave nodes available. Each time a build job is started due to a change on a branch in Git, Jenkins apparently pick a random free build node with a fresh, clean workspace meaning no incremental build speedup.
We have tried to build via NFS, such all the build nodes can share the workspaces, but at least the NFS server we have available is way too slow to make this work.
Is there anyway to make Jenkins choose the node a little less randomly and prefer the latest node on which the branch was build the last time?
Generally jenkins builds the code with the latest commit.Suppose in a build multiple commits have taken place.What I want is the list of commits that have been incorporated in the build.
Does anyone have a solution for this??
If you press changes in a job, you should get a list of all the commits that are new for each build of that job.