Jenkins Error: org.xmlpull.v1.XmlPullParserException - jenkins

I have installed successfully Jenkins after the next day, I have tried to reopen by restarting the Service:Jenkins and got this error.
Should I reinstall Jenkins ?
Thank you.

To get rid of the lockout follow these steps to manually change the version, which could just be back to your old working version.
Stop the Jenkins windows service
Rename war directory to war.bak
Rename jenkins.war to jenkins.war.bak
Get a new war file from https://updates.jenkins.io/download/war/
Copy new jenkins.war into jenkins directory
Start Jenkins windows service
Observe creation of war directory which will now contain contents of jenkins.war archive
Navigate to jenkins home page, at which point you will be informed
that Jenkins is preparing your installation
Once complete, test your
existing jobs to verify compatability
Navigate to 'Manage Jenkins'
via the menu and Action any notifications displayed - plugins, data
format conversions etc.
Delete jenkins.war.bak file and war.bak folder
After following those steps you will be able to get back into Jenkins, you might have other version issues with plug-ins but at least you can get back in and not lose everything. Also always put your pipeline scripts in source control and use a back up plug in for Jenkins.

Related

Upgrade Jenkins CI withourt losing User/Job Config

I would like to upgrade Jenkins to the latest version without losing job/user configuration.
From looking through various posts the answer seems to be to replace the jenkins war directory.
I did this and although the new version seems to be in place the about dialogue still has the original version,
I think this is because the versionnumber is held in a config file outside of the war folder.
Is there a better method to upgrade.
I have the best practice with replacing jenkins.war file, content of the folder should got extracted from war file during server startup (automatically).
All configuration is stored as files in jenkins home directory.
jobs in subfolder jobs, users in users etc.
So if you will replace war file, you will dont loose the configuration or content.
You can check this for better info, looks for "Install the New Jenkins War File
"
I am sharing my experience here, as this would definitely help someone. We were on jenkins 2.138.3 and wanted to upgrade to 2.235.5 version. Now the issue we were facing is our users were getting deleted when we tried to restore the users folder from the backup of old jenkins.
Root Cause: In the jenkins upgrade the mechanism to store the users on the disk is changed. This is verified by seeing the users//config.xml of both old and new jenkins.
The first problem we faced starting the jenkins is below error
java.nio.file.DirectoryNotEmptyException: /Users/jenkins/<username>
The reason being, in the upgraded jenkins the username folder is changed. for e.g. if your username is admin then in new jenkins the folder would be something like $JENKINS_HOME/users/admin_6635238516816951048/ instead of $JENKINS_HOME/users/admin/ and this mapping is captured separately in a file
$JENKINS_HOME/users/users.xml where a sample entry would look like
<entry>
<string>admin_6635238516816951048</string>
<string>admin_6635238516816951048</string>
</entry>
Here the first String is your username and second is the folder where config.xml for your user should exists.
In our old jenkins this folder structure is not available and hence we see the error
java.nio.file.DirectoryNotEmptyException: /Users/jenkins/<username>
So, what are the steps to migrate users properly so existing credentials can be used.
Once the new jenkins war is deployed on the new jenkins, stop the jenkins.
If there exists a users.xml file in $JENKINS_HOME/users/users.xml, delete it or rename it so jenkins wont look for the new folder structure
Restore your users folder from old jenkins to new jenkins at $JENKINS_HOME location. So all your users should appear in new jenkins # $JENKINS_HOME/users folder
Start the jenkins service.
And you should be able to login with your old jenkins user's credentials.
The detailed explanation can be found at
https://www.jenkins.io/doc/upgrade-guide/2.138/#SECURITY-1072

How to stop Jenkins TFS plug in from deleting workspace

I have a working Jenkins TFS setup, but can't figure out how to stop the Jenkins TFS plugin from deleting the whole workspace and downloading it again each time.
I just want it to do the equivalent of "Get Latest" and not delete any files that are up to date.
Here is the message I'm getting in the console when this happens:
Deleting workspace as the configuration has changed since a build was performed on this computer.
I can't figure out what is causing this or how to disable this behavior.
This doesn't always happen when I build the project, so something is causing this to happen.
It can happen even if I don't change any configuration stuff in Jenkins.
Option to "Delete workspace before build starts" option is off.
I have found the message in the Java source for the TFS plugin here, but
don't understand what is causing it: Java TFS Plugin in GitHub
Environment:
Jenkins v2.60.3
TFS plugin 5.121.0
Windows 10 64-bit
Java 1.8
Console log when this happens:
Building on master in workspace D:\Jenkins\workspace\XXX
Deleting workspace as the configuration has changed since a build was performed on this computer.
Downloading list of workspaces from https://tfs.company.com/tfs/Projects...
Deleting workspaces named 'MASTER-XXX' from computer 'ALAN-XXX'...
Deleted 1 workspace(s) named 'MASTER-XXX'.
Querying for remote changeset at '$/XXX' as of 'D2017-08-29T09:46:26Z'...****
In your Jenkins Project configure Page ,there is an option for deleting workspace before build starts in Build Environment section. Double check if you are checking this option or not.
The plugin checks the latest build configuration and compare it with the current job. If there is any difference/change exist, you will see that message. The configuration it checks is the settings in "Source Code Management". Since you mentioned that it also occurs when you didn't do any change, I suspect that it may caused by some variables you used in "Workspace name" changed. You can also check and compare the "build.xml" for the two builds in Jenkins Jobs folder to see what change cause the issue you meet.

Jenkins service won't start after backup

My organization needs to make backups of our heavily customized Jenkins instance. After doing some research on different methods for backing up Jenkins, we decided to go the route of copying the whole Jenkins directory using xcopy and then moving the backup to a new instance on a different machine. (The reason for using xcopy is that its the only way to preserve they symbolic link files within each job.)
Here's the steps I have taken:
A batch file uses xcopy to copy the entire D:\Jenkins directory on a nightly basis from the old machine
I install a fresh instance of Jenkins on a new server
I stop the Jenkins service from running
I delete the current Jenkins directory in the new machine and then xcopy the backup in its place
I attempt to start the Jenkins service and I am met with the following error:
The Jenkins service on Local Computer started and then stopped. Some
services stop automatically if they are not in use by other services
or programs.
I have tried running jenkins.war from the command line and that just causes a Jenkins instance to start up that doesn't register as a windows service, and I cannot login to (even after disabling useSecurity), and looks like it doesn't have our modifications present.
I have also tried clearing the application log and that did not help.
I am not sure how to get the Jenkins service up and running.
The one folder you need to backup is the one referenced by the environment variable JENKINS_HOME
It is best to keep that folder separate from the installation folder like C:\Program Files (x86)\jenkins.
Then I prefer using a tomcat instance, and copy the jenkins.war in it: it is easier to upgrade:
Simply overwrite your jenkins.war with the new version. Tomcat should automatically redeploy the application.

Jenkins lost the jobs after bulk upgrading the plugins

I new this could be an old post, but wanted to understand and fix my issue:
I have a maven job in jenkins which works fine when I build it.
I saw an alert for existing plugins i.e update available, so I selected all plugins and did update; all of a sudden I lost my old projects/jobs in jenkins but the jenkins folder structure is still having the jobs.
Tried:
copy pasting the job folder from my backup-- didn't fix the issue.
installing a new jenkins.war file had showed the project/job in folder structure but not in dashboard
had tried to create new maven project but not getting maven option after clicking on jenkins>>New item>> no maven project here..
Any suggestions please.

Jenkins Job disappeared after restart

I have this strange problem in Jenkins 1.5.31 .
I had configured Maven jobs which I still see in Jenkins_Home directory. My Jenkins Windows service was not getting started even though I could still access the Jenkins on default port 8080.
When I found in event viewer found that service is trying for 8080 which it found to be in use, so I did taskkilPID using the 8080 port process and it successfully restarted the Windows Jenkins service.
However, when I opened the Jenkins URL, I saw only two of my jobs were there and rest disappeared.
Has any one faced this issue?
I checked plugins and found that Maven project plugin installed is 1.5.3.1 and 2.1 is available but it has message -Warning: This plugin is built for Jenkins 1.538 or newer. It may or may not work in your Jenkins.
I don't see those jobs in config.xml and nor in its old copy backup.
After Jenkins restarts, there is the case when some jobs are missing if the syntax in their config.xml contains errors.
Check Jenkins logs for errors (Manage Jenkins/System Log)
Fix the errors in config.xml of each job. ( path: JENKINS_HOME/jobs//config.xml)
Restart jenkins or choose option reload configurations from disk (Manage Jenkins/Reload Configuration from Disk).
When all errors are fixed the job should appear. You can validate your configurations against some online tool, f.e.: https://www.xmlvalidation.com/
Another case is when all Jenkins jobs are missing and an empty dashboard is loaded. This indicates that Jenkins home directory is wrong, so make sure to specify JENKINS_HOME correctly and restart Jenkins.
This happened to me too after a restart. But it was not because of errors in the config.xml, but because another containing folder with the same name but in different case existed on the server.
I don't know how this happened, but after copying over the jobs from the second folder and reloading the folder the job came back up again.
For e.g: the job that went missing was FOLDER-NAME/jobs/job-name
On the Jenkins server, on disk, there was both
FOLDER-NAME/jobs/job-name
folder-name/jobs/job-name
After copying the folder FOLDER-NAME/jobs/job-name to folder-name/jobs/
and reloading the folder (https://<jenkins-host>/jobs/FOLDER-NAME/reload) the job came back up.
Upgrade Jenkins to the latest version.This will fix the problem

Resources