Jenkins jobs, history, users - all missing after a reconfigure - jenkins

This question has been asked multiple times around however 'Reload from disk' didn't work for me.
I opened my local Jenkins after a month, this time it asked me to reconfigure everything including the plugins as well as admin user (it had generated a new password). Moreover, my old jobs, build history, scripts etc. everything has gone missing. I have tried 'Reload from disk', but it did not work. I checked for most known places to see if my folders are available but they aren't.
Please can anyone help me get at least my scripts back?

Related

How to get Jenkins lastBuild API working with multi-branch pipelines?

I've had no problems getting last build details out of Jenkins in the past, but I've struck a weirdly-configured corporate environment, where the API urls are structured like this:
https://example.com/job/group-name/job/project-name/api/json
I can find the last build for a specific branch in this heirarchy:
https://example.com/job/group-name/job/project-name/job/branch-name/lastBuild/api/json
But how to get the last build of a project regardless of branch has defied all my efforts so far.
I can tell you that the obvious (and all non-obvious variations that I've tried) truly, seriously don't work. For instance, this is a complete failure:
https://example.com/job/group-name/job/project-name/lastBuild/api/json
And returns "This page isn’t working example.com redirected you too many times."
I'm guessing that the multiple copies of /job/ in the working URLs are a symptom of an unusual structure, so if anyone has any ideas I'm all ears!

Jenkins: Tracing the history of unsaved new test definition (copied from another test definition)?

Recently, in our enterprise production setup, it seems someone has tried to setup a new job / test definition by using another (copying) from identical job. However, (s)he seems to have NOT saved (and probably, am guessing here, closed the browser with the session being lost).
But the new job got saved though it was not set to stable or active; we knew about this because changes uploaded to gerrit, started failing in this newly setup partial job (because, these changes were in certain repos that met certain TDD settings).
Question: Jenkins system does not have trace of who setup the system in 'configure versions' option. Is there anyway to know the details of who setup the job / when was that done ?
No, Jenkins does not store that information by default.
If your Jenkins instance happen to be running behind an Apache or Nginx web server, there might be access logs that can help you. To find out when the job was created you could look at when its config.xml file was created/modified.
However, there are a few plugins that can add this functionality so that you won't have this problem again:
JobConfigHistory Plugin – Tracks changes in your job configurations and gives the ability to restore old versions.
Audit Trail Plugin – Keeps a log of who performed particular Jenkins operations, such as configuring jobs.

How to find out who changed the permission settings in Jenkins?

I am using Folder plugin and AD groups to control access to folder. This morning a team can't access their project anymore and later I found the AD group assignment in Assign Roles has been changed to wrong groups. Is there a way to find out which id did it? We only have a few admin ids.
Jenkins does not appear to keep an audit trail by default, as stated in this post on cloudbees.com, the folks that develop Jenkins.
The relevant lines:
Many Jenkins users look for a recommend a strategy for keeping an audit trail. This article is supposed to be a gap filler until more comprehensive compliance capabilities in JE/JOC are developed.
There are two open source plugins that enable you to track “WHO did WHAT?” in Jenkins:
...
The first plugin listed is Audit Trail Plugin which looks to provide exactly what you are seeking.
The description from the plugins page:
Keep a log of who performed particular Jenkins operations, such as configuring jobs.
This plugin adds an Audit Trail section in the main Jenkins configuration page. Here you can configure log location and settings (file size and number of rotating log files), and a URI pattern for requests to be logged. The default options select most actions with significant effect such as creating/configuring/deleting jobs and views or delete/save-forever/start a build. The log is written to disk as configured and recent entries can also be viewed in the Manage / System Log section.
I spent a few minutes looking through Jenkins various xml and log files, but could not find a log that contained something useful (username and/or timestamp). In this case it seems user auditing isn't built into Jenkins as of yet. Unfortunately it appears that you might not be able to determine who made those changes after the fact.

hudson: way to get the user value who initiated the build?

Is there a way to get the hudson job initiated user name.
Is it possible to get using script shell, py etc.
Lets assume I have the build # which was initiated. I know how to get the latest build info using api but would like to get a user details for a specific job.
Do you think, this will work for hudson? :)
https://wiki.jenkins-ci.org/display/JENKINS/Build+User+Vars+Plugin
Thanks in advance
That plugin will not work with Hudson, unless you download a very old version of the plugin. I'm not sure how many people are still using Hudson and haven't upgraded to Jenkins.
Anyway, when a user manually triggers a build, this is called a "user cause"; there are other types of cause, e.g. SCM trigger.
You can use the JSON or XML API to get the causes for a build, for example:
https://ci.jenkins-ci.org/job/remoting/lastSuccessfulBuild/api/xml?xpath=//action/cause/userId
In this case, this returns the username that caused the build to run.
Though note that there may be multiple causes for a build, and potentially other cause types that use the userId field.
This works in Jenkins, but it should also work in Hudson, but I haven't tested it.

Change configuration once, and gets multiple config change history

I work with a Jenkins server in which JobConfigHistory plugin is installed.
This server has been used for a while, and I think many other plugins are installed as well.
On this server, I get multiple config change history recorded when I make a change to job configuration.
I don't want this behavior; I want only single history change for a single configuration change.
I guess some Jenkins server config or some installed plugin is the cause of this problem, but I have no clue what I should do to find it out.
Any idea?
There is a Jenkins issue that has been resolved recently:
[JENKINS-22224] one job configuration change results in three Job Config History entries.
But:
Danny Staple added a comment - 20/Nov/14 5:17 PM
We are seeing a general problem here - some of the plugins appear (parameterizedTrigger, ThrottleConcurrentbuilds, NodeLabel, ExtendedChoice are current suspects) to do this too - we are now having as many as 8 (!!) saves in the config. For some plugins, it seems that when there is no change, they save a no-diff config. Almost as if each is doing their own save in order.
Marc Günther added a comment - 20/Nov/14 5:23 PM
+1
We are not using disk-usage plugin anymore, cause it's so slow, but I still see this behaviour. So it's definitely not restricted to disk-usage plugin alone....
The plugin persists the changes whenever the configurable entity is saved regardless there is any change or not. Note there is a global option for the plugin Do not save duplicate history to save only unique changes.

Resources