0

I am trying to start Jenkins in a Centos 7 machine. I am trying to copy the Jenkins folder from another machine to this machine and start it here instead of downloading. I copy the entire Jenkins files to /var/lib/jenkins folder in the new machine. I run the following command:

java -jar jenkins.war

I get the following log:

Running from: /var/lib/jenkins/jenkins.war
webroot: $user.home/.jenkins
2019-12-23 19:50:24.875+0000 [id=1]     INFO    org.eclipse.jetty.util.log.Log#initialized: Logging initialized @510ms to org.eclipse.jetty.util.log.JavaUtilLog
2019-12-23 19:50:25.019+0000 [id=1]     INFO    winstone.Logger#logInternal: Beginning extraction from war file
2019-12-23 19:50:26.607+0000 [id=1]     WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2019-12-23 19:50:26.676+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: jetty-9.4.z-SNAPSHOT; built: 2019-05-02T00:04:53.875Z; git: e1bc35120a6617ee3df052294e433f3a25ce7097; jvm 1.8.0_232-b09
2019-12-23 19:50:27.038+0000 [id=1]     INFO    o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2019-12-23 19:50:27.111+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2019-12-23 19:50:27.111+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2019-12-23 19:50:27.116+0000 [id=1]     INFO    o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 660000ms
Jenkins home directory: /root/.jenkins found at: $user.home/.jenkins
2019-12-23 19:50:27.795+0000 [id=1]     INFO    o.e.j.s.handler.ContextHandler#doStart: Started w.@782a4fff{Jenkins v2.190.1,/,file:///root/.jenkins/war/,AVAILABLE}{/root/.jenkins/war}
2019-12-23 19:50:27.818+0000 [id=1]     INFO    o.e.j.server.AbstractConnector#doStart: Started ServerConnector@1040be71{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2019-12-23 19:50:27.818+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: Started @3454ms
2019-12-23 19:50:27.819+0000 [id=21]    INFO    winstone.Logger#logInternal: Winstone Servlet Engine v4.0 running: controlPort=disabled
2019-12-23 19:50:29.635+0000 [id=28]    INFO    jenkins.InitReactorRunner$1#onAttained: Started initialization
2019-12-23 19:50:29.674+0000 [id=28]    INFO    jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2019-12-23 19:50:31.654+0000 [id=29]    INFO    jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2019-12-23 19:50:31.666+0000 [id=29]    INFO    jenkins.InitReactorRunner$1#onAttained: Started all plugins
2019-12-23 19:50:31.684+0000 [id=29]    INFO    jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2019-12-23 19:50:32.651+0000 [id=31]    INFO    jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2019-12-23 19:50:32.691+0000 [id=46]    INFO    hudson.model.AsyncPeriodicWork$1#run: Started Download metadata
2019-12-23 19:50:32.708+0000 [id=46]    INFO    hudson.util.Retrier#start: Attempt #1 to do the action check updates server
2019-12-23 19:50:33.763+0000 [id=32]    INFO    o.s.c.s.AbstractApplicationContext#prepareRefresh: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@3a900fc3: display name [Root WebApplicationContext]; startup date [Mon Dec 23 14:50:33 EST 2019]; root of context hierarchy
2019-12-23 19:50:33.764+0000 [id=32]    INFO    o.s.c.s.AbstractApplicationContext#obtainFreshBeanFactory: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@3a900fc3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@44b26de3
2019-12-23 19:50:33.777+0000 [id=32]    INFO    o.s.b.f.s.DefaultListableBeanFactory#preInstantiateSingletons: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@44b26de3: defining beans [authenticationManager]; root of factory hierarchy
2019-12-23 19:50:33.986+0000 [id=32]    INFO    o.s.c.s.AbstractApplicationContext#prepareRefresh: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@16d60366: display name [Root WebApplicationContext]; startup date [Mon Dec 23 14:50:33 EST 2019]; root of context hierarchy
2019-12-23 19:50:33.987+0000 [id=32]    INFO    o.s.c.s.AbstractApplicationContext#obtainFreshBeanFactory: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@16d60366]: org.springframework.beans.factory.support.DefaultListableBeanFactory@53d5b029
2019-12-23 19:50:33.987+0000 [id=32]    INFO    o.s.b.f.s.DefaultListableBeanFactory#preInstantiateSingletons: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@53d5b029: defining beans [filter,legacy]; root of factory hierarchy
2019-12-23 19:50:34.237+0000 [id=32]    INFO    jenkins.install.SetupWizard#init:

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:



This may also be found at: /root/.jenkins/secrets/initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

2019-12-23 19:50:53.162+0000 [id=46]    INFO    hudson.util.Retrier#start: The attempt #1 to do the action check updates server failed with an allowed exception:
java.net.SocketTimeoutException: connect timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:607)
        at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
        at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
        at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1570)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
        at hudson.model.DownloadService.loadJSON(DownloadService.java:167)
        at hudson.model.UpdateSite.updateDirectlyNow(UpdateSite.java:189)
        at hudson.PluginManager.checkUpdatesServer(PluginManager.java:1762)
        at hudson.util.Retrier.start(Retrier.java:62)
        at hudson.PluginManager.doCheckUpdatesServer(PluginManager.java:1733)
        at jenkins.model.DownloadSettings$DailyCheck.execute(DownloadSettings.java:130)
        at hudson.model.AsyncPeriodicWork$1.run(AsyncPeriodicWork.java:101)
        at java.lang.Thread.run(Thread.java:748)
2019-12-23 19:50:53.163+0000 [id=46]    INFO    hudson.util.Retrier#start: Calling the listener of the allowed exception 'connect timed out' at the attempt #1 to do the action check updates server
2019-12-23 19:50:53.165+0000 [id=46]    INFO    hudson.util.Retrier#start: Attempted the action check updates server for 1 time(s) with no success
2019-12-23 19:50:53.166+0000 [id=46]    SEVERE  hudson.PluginManager#doCheckUpdatesServer: Error checking update sites for 1 attempt(s). Last exception was: SocketTimeoutException: connect timed out
2019-12-23 19:50:53.170+0000 [id=46]    INFO    hudson.model.AsyncPeriodicWork$1#run: Finished Download metadata. 20,477 ms
2019-12-23 19:50:54.258+0000 [id=32]    WARNING hudson.model.UpdateCenter#updateDefaultSite: Upgrading Jenkins. Failed to update the default Update Site 'default'. Plugin upgrades may fail.
java.net.SocketTimeoutException: connect timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:607)
        at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
        at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
        at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1570)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
        at hudson.model.DownloadService.loadJSON(DownloadService.java:167)
        at hudson.model.UpdateSite.updateDirectlyNow(UpdateSite.java:189)
        at hudson.model.UpdateCenter.updateDefaultSite(UpdateCenter.java:2456)
        at jenkins.install.SetupWizard.init(SetupWizard.java:168)
        at jenkins.install.InstallState$InitialSecuritySetup.initializeState(InstallState.java:166)
        at jenkins.model.Jenkins.setInstallState(Jenkins.java:1089)
        at jenkins.install.InstallUtil.proceedToNextStateFrom(InstallUtil.java:96)
        at jenkins.install.InstallState$Unknown.initializeState(InstallState.java:84)
        at jenkins.model.Jenkins$16.run(Jenkins.java:3277)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1118)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
2019-12-23 19:50:54.273+0000 [id=32]    INFO    jenkins.InitReactorRunner$1#onAttained: Completed initialization
2019-12-23 19:50:54.302+0000 [id=20]    INFO    hudson.WebAppMain$3#run: Jenkins is fully up and running

The log clearly says that Jenkins is up and running. But when I try to check status, sudo service jenkins status, I get the following error:

Unit jenkins.service could not be found.

I am not sure what I am missing

3
  • Did your previous system have a Jenkins systemd service unit that you forgot to copy? Also, was it running it as a system account and not root?
    – jsbillings
    Dec 23, 2019 at 20:16
  • @jsbillings, does it make a difference running as system or root as root should be having all the privilege. I am new to this, just curious. Also I have zipped the entire contents from the other system in the Jenkins folder. I do not have access to other system to check now. Is there any workaround if I have missed something?
    – Geo Thomas
    Dec 23, 2019 at 20:22
  • It looks like you missed some files. It might make more sense to follow the instructions in the answer and copy over the config you saved from the other installation.
    – jsbillings
    Dec 24, 2019 at 15:01

3 Answers 3

3

Faced the same problem while installing Jenkins on AWS ec2 instance. The below commands worked for me.

  1. sudo amazon-linux-extras install epel -y
  2. sudo yum update -y
  3. sudo yum install jenkins java-1.8.0-openjdk-devel
1

There are a few things I would like to mention in this answer that I think can be helpful to you:

1) Issue

The issue you mention:

Unit jenkins.service could not be found.

happens because when you run the war file the unit file is not created.

If you used a default installation (defined here: https://pkg.jenkins.io/redhat-stable/) in your former machine, you'll find the unit file at /etc/init.d/jenkins. I'm not really sure if just copying the file to your newer machine will solve all your issues.

2) CentOS 7 and Systemd

CentOS 7 uses SystemD unit files instead of SysV init scripts, and if you take a look at /etc/init.d/README you can get more details about how CentOS manages init files placed in this directory.

... Traditional init scripts continue to function on a systemd system. An init script /etc/rc.d/init.d/foobar is implicitly mapped into a service unit foobar.service during system initialization.

Probably, in the future, the init files will be converted to native systemd unit files and will be placed in the directory /etc/systemd/system.

3) My recommendation

I would recommend you to install the RPM package or using a docker image (my preferred one). All the details are in the official documentation:

https://jenkins.io/doc/book/installing/

Please let me know if this was helpful.

2
  • "initd" is not the name of van Smoorenburg init. And you could at least point to the Jenkins installation instructions, which provide a systemd service unit.
    – JdeBP
    Dec 24, 2019 at 8:38
  • @jdeBP Thank you for your input. I point to the official Jenkins installation on the last step. I also edited the answer regarding the "initd".
    – Nuno Dio
    Dec 25, 2019 at 21:43
1

It says the unit is not found because the Jenkins package is not set up properly. The following commands will solve your problem..

$ sudo yum update –y
$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat/jenkins.repo
$ sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
$ sudo yum install jenkins -y

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.