Why don't my migrated Jenkins jobs display after migration from Windows to Linux? - jenkins

I recently migrated our windows instance of Jenkins to Linux. This was very easy as I just copied everything from %JENKINS_HOME% to the linux box.
However someone let me know they had their own personal instance of Jenkins that they wanted to rollover to the Linux VM. I copied the jobs folder from their Windows box, to the Linux VM but they dont show up in any of my views (including the ALL view). I also installed the Job Import plugin and it ran successfully as well but I have the same issue.
I'm not sure if I have to modify my config.xml to include these views or if there is another file that I need to merge with my Linux VM. I have also restarted the service and reloaded configuration from disk.
This is on Jenkins 2.0.
Does anyone have any thoughts on what I may have missed?

Based on the comment of TheEllis:
The copied job files must have the same owner as the jenkins instance runs under. Furthermore read/write/execute permission for the owner should be set, too.

Related

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 Service vs Jenkins Jar File Permission

I have Jenkins 1.6 installed as a service on a CentOS machine.
At some point in the past the service stopped/crashed/? and Jenkins was restarted from the command line, java -jar jenkins.war, as the root user.
While it was running as root some plugins were updates/installed, and jobs created created/ran. Any new files created are now owned by the root user/group and not by the jenkins user/group.
Meaning, when the service was restarted Jenkins could not read these files. Resulting in plugins not running and most jobs not being loaded.
Manually restoring the permissions(chown, chgrp) to the plugins solves the plugin related issues.
For the jobs it's easy to spot new ones and fix them. Any existing ones that were re run and created new files are more difficult to find.
Then there may be other files which the Jenkins server created, not as part of a job or plugin which need to be changed. The errors are not always obvious, and crop up slowly over time.
Am I better adding the jenkins user to the root group? could this cause issues?
Or manually changing the permissions, hope i got them all! And fix others that come up?
Any suggestions appreciated.
In the end we manually changed the file permissions back to Jenkins. There were some immediate jobs that failed in the following days. And a few which only came up a few months later.
For the most part it worked well.

Jenkins slave agent service do not work since java update (which removed medium security level)

Situation:
Yesterday morning, all of our Slaves had problems (because thanks to Java, which removed the medium security level, the Jenkins slave agent could not be launched anymore). Java then started blocking all Jenkins slave agent.jlnp, we had to add on every slave an exception for our jenkins server, so the slave application can be launched. This was annoying but now they work. (was there an easier solution?)
Few slaves had Jenkins installed as a service (to be launched automatically on startup). However, since yesterday, they do not launch anymore, and we cannot find why. It probably has to do with the security from Java.
Someone has any idea?
You need to update jenkins reference to Java. It is in file C:\Jenkins\jenkins-slave.xml (or whereever is your Jenkins folder). When you updated Java Jenkins no longer knows where to find new version
Mine looks something like this.
<executable>C:\Program Files (x86)\Java\jre1.8.0_91\bin\java.exe</executable>
I made it works with the following steps:
1-) Uninstalling service
2-) Reboot
3-) Installing service
4-) Reboot

Jenkins runs as root instead of Jenkins

I have a newly installed jenkins server running on my computer, and am having some issues related to permissions.
It seems that jenkins creates the workspace directory as the root user, and then of course all task (including even pulling from the repository) fail, because they do not have permissions to modify the directory
Have a look at the Started-By Environment Variable plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Started-By+Environment+Variable+Plugin
If you are just asking how to set up Jenkins to run under a different user in Linux it depends on how you installed it. Have a look at https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins for different setup options. I had a look at Installing Jenkins as a Unix daemon and at step 7 you need to setup a configuration file. Change the last line in that file (RUN_AS_USER=jenkins) to contain the user of your choice.

Renistall of Jenkins on Windows

I may need to reinstall Jenkins on a Windows Server 2008 R2 Enterprise server. If I run the installer for an already installed version, it gives me the option of uninstalling. I've already tried the "repair" option but it didn't solve my problem. If I do the uninstall, what will happen to my existing jobs and their history? Will the entire Jenkins folder be deleted? If so, will I be able to restore them from a backed up copy?
I'm not sure about Windows, but I think in linux, the jobs/configs directory can be copied across multiple Jenkins installations. Make a backup of your jenkins home directory first. The Jenkins executable itself is less critical, as it can easily be reinstalled without affecting your build environment. See this link for more information: https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins
Yes, you can restore them by backing up your jenkins install folder and then copying the contents back to the jenkins install folder after reinstallation. This works for linux or windows. All job info and configuration is stored on the file system.

Resources