How to delete inactive jobs older than 6months in jenkins - jenkins

I have 2000 plus jobs in my dev-jenkins,I want to remove inactive job older than 6 months in Jenkins and also there workspace which is present on different slave.
Jenkins version using- 1.580.3
Thanks in advance.
Ayush

There are no official solution to do that (= plugins or native Jenkins functionality).
You can find a Groovy script here which delete the inactive workspaces:
http://jenkins-ci.361315.n4.nabble.com/automated-deletion-of-workspaces-td3799739.html
Another Groovy script to clean the workspaces (to be updated because it's actually checking the remaining free space):
https://gist.github.com/rb2k/8372402
You can schedule a maintenance job on all your slaves to launch on of these two scripts.
There is also the Jenkins Workspace Cleanup plugin which can clean the workspace before or after the build.

I'd like to suggest the plugin to 'shelve' the unused job, so you can restore in future:
https://wiki.jenkins-ci.org/display/JENKINS/Shelve+Project+Plugin

Related

Preventing a build from running on the same node if it failed previously in Jenkins

Any plugins or default behavior in Jenkins that I could configure to force a build to be done on a different node if the previous build on a node was a failure?
To answer my own question, it appears there are not many plugins that allow you control over jobs running on Jenkins slaves and none that do this.

How to retrieve deleted Jenkins job?

Is there any method or plugins available to retrieve deleted Jenkins job?
I have mistakenly deleted one job from Jenkins. So please give a suggestion to undo the delete.
In fact you have just to use this url to reactivate your deleted job :
http://[url_of_jenkins]/jobConfigHistory/?filter=deleted
You just need to have this plugin installed beforehand: https://wiki.jenkins.io/display/JENKINS/JobConfigHistory+Plugin
It is not possible unless you somehow restore files from your master operating system. In future you can use plugin: https://wiki.jenkins-ci.org/display/JENKINS/JobConfigHistory+Plugin. This plugin saves configuration files for deleted jobs (but not build history).
Job configs are stored on disk under $JENKINS_HOME/jobs, so if you have a backup of that directory, then you can restore the job.
Otherwise, there's no "recycle bin" for deleted jobs in Jenkins.
In future, if you want to remove a rarely-used job from Jenkins, but there's a small chance that you might want to use it in the future, you can archive the job using the Shelve Project plugin.
Download Plugin Job Config History
Download steps:- Manage Jenkins -> Manage Plugin -> Available -> JobConfigHistory
Download and install
After Installation step:-
Jenkins -> Job Config History -> Show deleted jobs only
and restore the jobs
Peace...

Jenkins clone jobs and change branch

I have a task that I want to realize with Jenkins, but I don't know how to do it.
I have a view full of jobs, all pointing to the same svn repo. Each job build one maven module present on the svn repo.
Once a year, we release a version, and therefore we create a new branch for the development on the future new version.
In Jenkins, it means that I want a view with all my jobs pointing on the released version branch, and a new view with the same jobs, but pointing on the future version branch.
I know that I can do that manually by cloning and then modify the branch for all the jobs, but I want to do that with the least number of actions possible (ideally one :-)).
I take a look at Jenkins built-in possibilities and in existing plugins, but I found nothing and I have no idea how to do it.
Is there a possibility to script that kind of job ? Or a plugin doing that ?
Thank you,
Seb
I suppose your future versions are developed on the trunk. So the URL for these versions is always the same (ex: http://svn.yourcompany.com/project1/trunk).
I propose to group your trunk jobs in a dedicated folder using the CloudBees Folder plugin.
This plugin will group all your jobs in a physical folder in your Jenkins home folder (ex: jobs/trunk).
When you want to create the new jobs for the release branch, you write a script which:
Copy the jobs/trunk folder into jobs/release_2.0
Replace http://svn/.../trunk with http://svn/.../branches/2.0 (you can use a regexp to do that)
Rename all the jobs (you just need to add 2.0 at the end of all job names)
Reload the Jenkins configuration
It should work :)

Jenkins Multiple SCM - All SCM's triggering build

I have a Jenkins job that includes an Android app and a common library. I use Jenkins' Multiple SCM plugin to download both git repos and then build and run.
The common library gets updated more frequently than the app, and sometimes these updates break compatibility with the App. When the App gets updated and committed, its generally guaranteed to have fixed any incompatibilities against the latest library version.
The jenkins job should trigger only for commits to the App. Under the common lib SCM, I have added "Don't trigger a build on commit notifications" as well as "Polling ignores commits from certain users" excluding "*".
However, this job still gets run when commits happen to the lib, resulting in a lot of broken build notifications. What am I doing wrong?
Thanks.
under SCM 'Advanced clone behaviors', select 'Polling ignores commits in certain paths' and set 'Excluded Regions' to '.*'
Maybe it's better to switch from polling to post-commit hook, like described here?

Jenkins schedules 3 builds on first build

I am creating a build that has 3 (sub builds) using the Parameterized Trigger Plugin to fire the builds I need built in a specific order.
The main build is using the Jenkins GIT plugin to monitor the repos I need so it can be triggered by a push to the branch I've declared.
The thing is, when I create the build at first (This is done through autojenkins) and trigger it to build, it builds but then in the middle of the first build a second build is scheduled and in the middle of the seconds build a third build is then scheduled, effectively building the same project 3 times in a row, although there has been no changes to the repos.
The reasons for build 2 and 3 are the same: Started by an SCM change but there is nothing to see in the polling log.
Can this behaviour be explained somehow?
Any help is greatly appreciated!
Here's some info on Jenkins:
Jenkins v 1.529 running on Ubuntu 12.04 on Amazon
Jenkins GIT plugin v 1.5.0
Parameterized Trigger Plugin v 2.20

Resources