How to rename Jenkins build status - jenkins

Jenkins build statuses are SUCCESS, FAILURE , UNSTABLE and ABORTED
I would like to rename UNSTABLE status to something else, i.e. ERROR.
How can it be done without patching Jenkins source code?

The best and only way is patching the jenkins source code.
Because, Jenkins doesn't have feature of changing status name which are decided by open-source community.
I would rather suggest you to create a plugin as there is not any plugin out there that can solve your problem.

Related

GitHub Organization job is missing from list of Jenkins jobs

I am following this Jenkins tutorial. After installing Jenkins, I manually add the missing recommended plugins. I then try to create a new Jenkins job. I notice that the GitHub Organization option is missing from the list. I am using version 2.375.1 (latest as of now). Why is this happening? How can I fix it? Is it missing any kind of plugin?
The GitHub Branch Source plugin is responsible for that, and is automatically installed if you selected the defaults when starting Jenkins. This is also highlighted in the Jenkins docs.
However, the job type is no longer GitHub Organization, and is instead called Organization Folder, which "enables Jenkins to monitor an entire GitHub Organization". The functionality is the same.

Jenkins job config.xml not reflecting the plugin usage

tl;dr : Plugin mentioned in Jenkins jobs config.xml is not matching the Plugin used in the JenkinsFile/Groovy script.
I've landed up with a Jenkins server, that is actively used and unfortunately not updated.
Owing to this, the Jenkins version is old and most of the plugins need urgent, as they are having vulnerabilities.
Now this is a system with 209 Plugin and too many jobs having multi-branch pipelines.
I started with:
def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins() plugins.each {println "${it.getShortName()}: ${it.getLongName()} : ${it.getVersion()}"}
The outcome was useful, I got an elaborate list of plugins in the system.
In my attempt to chart out the job -> plugin dependencies, I started out using this solution supplied by another stackoverflow user. The output was really useful, as it classified which plugin is being used by which job.
The thing that baffled me was, out of those 209 odd plugins, only 20 were being used across all the jobs.
To be precise, say a job's JenkinsFile explicitly mentions usage of ansible plugin, from what I read the config.xml of that job should have ansible plugin mentioned, in my case it doesn't list the ansible plugin in it.
Usage of Plugin-Usage plugin is ruled out for now, as there are dependent plugins that need to be updated.
Can someone please advise me what should be my approach to this. I dont want to update a plugin and regret finding 100 of jobs failed the next day.

Jenkins polls a wrong branch

I have configured my branch for a Pipelines project like this:
*/master
However, according to the Git poll log:
[poll] Latest remote head revision on refs/heads/ci_test is:
c945253a1f3aed6be113347e37aa3512db43bcf0 - already built by 17 Done.
Took 11 sec No changes
It always tries to poll ci_test that was the branch I initially tested with. Same thing with BitBucket webhook. It reacts only on the ci_test branch despite that fact that only master is now configured, applied and saved. I also tried to restart Jenkins with no luck.
Any ideas how to debug this?
Edit: If I trigger the build manually it builds master. The poller still polls ci_test no matter what. Wtf?
Edit2: Setting the branch to any (leave blank) fails to fetch anything even manually.
The solution that worked for me was:
Delete all configuration related to polling (trigger clause in the pipeline, polling configuration in the job)
Run a build manually (it should build the correct branch)
Restore polling configuration
After these changes, polling restarted and began to query the correct branch.
The "solution" was to move on to a Multibranch Pipelines project. The legacy Pipelines project seems to be confusing and broken with multiple branches anyway:
https://issues.jenkins-ci.org/browse/JENKINS-46588
Additionally the webhook might also be somehow buggy, but this multi-branch project type seems to be working much better.
For me the issue was that I had specified "Branch Specifier" as */* and changing that to empty value fixed the problem, as instructed: (blank for 'any').
Probably for you case you should put 'master' instead of */master
Seems to be that the problem is with webhook on BitBucket, not with Jenkins configuration. Probably webhook was created for ci_test branch and now doesn't see the changes for master branch.
I have this issue (our Jenkins server hasn't been updated for a couple of years, so pretend the date on this post is 2017). I believe it's because of this bug (I believe both are the same problem):
https://issues.jenkins-ci.org/browse/JENKINS-50168
https://issues.jenkins-ci.org/browse/JENKINS-55524
I don't have a solution, although I'll update this answer if the multi-branch pipeline works.
Be sure that you don't have enabled the Lightweight checkout checkbox in the Pipeline section.
Unfortunately, it's not compatible to Bitbucket webhook plugin..

Is there a way to turn Jenkins job into a Jenkins DSL script automatically?

I use Job DSL Plugin to generate my Jenkins builds. But sometimes I make small changes to the build in Jenkins and I want to port those changes back to my DSL script automatically. Is there any way to achieve this?
Currently there is no way to generate a Job DSL script for an existing job. This has been reported in the Jenkins issue tracker as JENKINS-16360 some time ago and someone even offered a bounty, but AFAIK no one is working on the issue.

Jenkins automation

Is there any way in jenkins where as soon as we detect the failed build, job revert back the perforce code to the last successful build changelist and fire a build again.
Flow -
1. so as soon as we have failed build - Notifcation will be sent out to dev team with possible checkins which causing the build failure
Revert back the recent code to the last working code and submit it
Initiate a build.
It is possible, but I don't see any reasons or use case to do it as it is not a correct workflow and can be confusing.
But if you decided to do it, the next steps are required:
Example how to do it using Perforce source control.
Steps inside job settings:
Before build triggers you need to save latest changelist number $P4_CHANGELIST - 1
Perforce plugin for Jenkins: Perforce plugin for Jenkins
Build
Get last error code
Get last error code from the: batch
If code != 0 then checkout and build changelsit $P4_CHANGELIST - 1
Jenkins is not a production server. It runs tasks and do not have options that I know for that purpose.
What is your source code ? webapps ? others ?
What steps are you performing ?
Are you performing some automatic tests ?
My assumption is that you got some tests that may invalidate the build.
These tests should be runned :
* on a mock server to prevent deploying on your server
* or somewhere else
Like that, if build failed, nothing is deployed.
If build success, you can deploy your project normally.
If this not reply to your answer, please provide requested information to undestrand a bit more your job process.
If your using an artifact repository like Nexus or Artifactory to manage your project artifacts then you could always redeploy the previous working version of your application when a failure is detected.
Your not cancelling any checked in code that potentially broke the build but you are preserving your test environment. You can configure Jenkins to notify the user who checked in the latest erroneous change set and they can work on resolving the issue.
Jenkins also provides a rich API which allows you to delete a job, start a job, get information about previously run jobs. You could leverage some of these services along with your artifact repo to achieve the experience you described.

Resources