Jenkins website root path
Asked Answered
A

11

32

I'm trying to follow the directions here: https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache to set up my Jenkins server to appear at http://myhost/jenkins. It works, but the Jenkins website thinks http://myhost/ is the jenkins/ root.

I believe this problem is caused by the first warning flag on that web page, i.e. that my context path is not set correctly. However, I can't figure out where to set the context path. The instructions for ubuntu and windows are clear enough, but on Mac OS X 10.6, there is no jenkins.xml file, no /etc/default/jenkins file, and nothing of relevance I can see in ~/.jenkins/config.xml.

So, what am I missing? Where can I tell jenkins that its root is in /jenkins/ instead of /?

Axiology answered 1/2, 2012 at 1:35 Comment(2)
I never succeeded at hooking up jenkins & apache, I've just ended up using SSH tunneling instead.Axiology
Here is the solution worked in Windows environment. https://mcmap.net/q/454036/-jenkins-url-with-computer-name-does-not-open-pageRubi
I
15

Not sure where to look in config.xml, but at http://myhost/jenkins/configure, there's an option called "Jenkins URL" that you can use to set that.

Indole answered 1/2, 2012 at 1:40 Comment(1)
I've tried changing that URL to be /jenkins/, jenkins/, and http://myhost/jenkins/, and none of the three worked. From the help on that item: Optionally specify the HTTP address of the Jenkins installation, such as http://yourhost.yourdomain/jenkins/. This value is used to let Jenkins know how to refer to itself, ie. to display images or to create links in emails. This is necessary because Jenkins cannot reliably detect such a URL from within itself. your answer is correct, though.Axiology
B
32

Paraphrasing from the document you mentioned;

You need to specify the context/prefix of the Jenkins instance, this can be done by modifying the Jenkins configuration as follows; Either, set the context path by modifying the jenkins.xml configuration file and adding --prefix=/jenkins (or similar) to the entry. Or Set the context path when using by adding --prefix=/jenkins to JENKINS_ARGS in /etc/default/jenkins (Ubuntu) or in an appropriate startup file.

So, how to find these things...

The Jenkins.xml file should be in the $JENKINS_HOME directory, I'm not sure if Mac OS has the "updatedb" and "locate " commands, but you could try doing updatedb && locate jenkins.xml

Also, have a look in the startup scripts; /etc/init.d if installed from a package, or add the JENKINS_ARGS to the environment properties for the User running Jenkins (append to ~user/.profile) or the arguments for the container running Jenkins.


Be aware that if your Jenkins installation (without the prefix argument) was running under:

http://myserver:8080/ => 200 Jenkins is here

adding --prefix=/ci/dashboard in the arguments will produce this behaviour:

http://myserver:8080/ => 404
http://myserver:8080/ci/dashboard => 200 Jenkins is now here
Benz answered 2/2, 2012 at 20:20 Comment(3)
Mac OS has updatedb and located; locate jenkins.xml turns up nothing. Similarly, find ~/.jenkins/ -name "jenkins.xml" returns nothing. The startup scripts on mac are different than linux, so I'll search those next.Axiology
In RedHat it's /etc/sysconfig/jenkinsSlipnoose
In Debian, modify /etc/init.d/jenkins: JENKINS_ARGS="--prefix=/jenkins"Bewray
I
15

Not sure where to look in config.xml, but at http://myhost/jenkins/configure, there's an option called "Jenkins URL" that you can use to set that.

Indole answered 1/2, 2012 at 1:40 Comment(1)
I've tried changing that URL to be /jenkins/, jenkins/, and http://myhost/jenkins/, and none of the three worked. From the help on that item: Optionally specify the HTTP address of the Jenkins installation, such as http://yourhost.yourdomain/jenkins/. This value is used to let Jenkins know how to refer to itself, ie. to display images or to create links in emails. This is necessary because Jenkins cannot reliably detect such a URL from within itself. your answer is correct, though.Axiology
C
13

Just to provide some recent confirmation of the suggested approaches, on CentOS 7, with Jenkins 1.610, I was able to achieve this by changing jenkinsUrl in jenkins.model.JenkinsLocationConfiguration.xml to the desired one (e.g. http://127.0.0.1:8080/jenkins), adding

JENKINS_ARGS="--prefix=/jenkins"

inside /etc/sysconfig/jenkins, and restarting Jenkins.

FYI the Jenkins installation was made via Puppet, using this Puppet module.

Chandigarh answered 18/8, 2015 at 12:2 Comment(0)
P
10
  1. Add prefix attribute to /etc/default/jenkins file:

    JENKINS_ARGS="--webroot=/var/cache/jenkins/war --prefix=/jenkins --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT

  2. Configure your web server (e.g. - nginx) to redirect /jenkins to localhost:8080;

Phonolite answered 30/12, 2014 at 13:42 Comment(0)
N
7

Put this into /etc/apache2/other/jenkins.conf:

ProxyPass         /jenkins  http://localhost:8009/jenkins
ProxyPassReverse  /jenkins  http://localhost:8009/jenkins
ProxyRequests     Off
<Proxy http://localhost:8009/jenkins*>
    Order deny,allow
    Allow from 127.0.0.1
</Proxy>

Then execute these commands:

sudo defaults write /Library/Preferences/org.jenkins-ci httpPort 8009
sudo defaults write /Library/Preferences/org.jenkins-ci prefix /jenkins
sudo launchctl stop org.jenkins-ci

The last command tells launchd to stop the running instance of Jenkins. And a new one will automatically be started because the launchd has been configured to always keep Jenkins running.

Nessim answered 22/3, 2012 at 22:35 Comment(5)
That's helpful, but I still have a few problems: 1. the icons etc. for Jenkins still don't load 2. "launchctl start error: No such process" on that last command - implies I don't have a launchtl-moderated instance of jenkins 3. I don't have /etc/apache2/other/jenkins.conf, so I put those in httpd.conf.Axiology
1. I don't know. You should check Apache logs at /var/log/apache2.Nessim
2. OK, I was assuming you are using the Jenkins Mac installer. If you are not, the last 3 commands above are not for you. Then you just need to start jenkins with command line parameters --httpPort=8009 --prefix=/jenkinsNessim
3. Yes, /etc/apache2/other/jenkins.conf does not exist. Apache will load all config files it finds in the "other" directory. But you can put the settings into httpd.conf too.Nessim
NOTE: the Apache configuration is (according to my understanding) set to allow connections from localhost only. Depending on your use, you might want to open it up a little bit.Nessim
M
6

This is how I fixed it under Debian Wheezy running Jenkin 1.557

  • in /etc/default/jenkins , modify the JENKINS_ARGS line by adding "--prefix=$PREFIX"

    JENKINS_ARGS=" ..... --prefix=$PREFIX"

Mesdemoiselles answered 3/4, 2014 at 9:43 Comment(0)
H
3

you need to edit jenkins config file in directory such like : sudo vi /etc/default/jenkins and change var HTTP_PORT next restart jenkins sudo /etc/init.d/jenkins restart

hope this is helpful

Habitant answered 25/10, 2012 at 18:32 Comment(0)
H
2

I'm using CentOS7, add JENKINS_ARGS="--prefix=/jenkins" to /etc/sysconfig/jenkins and restart Jenkins worked. Then you can visit via ip:8080/jenkins

Holotype answered 8/1, 2018 at 12:34 Comment(0)
A
0

I'm not sure if people are still looking for this, but as I just ran across it, I figured I'd post my solution here.

By following the instructions at here, I was able to set the context located in Library/Preferences/org.jenkins-ci.plist to a more preferable address. The link has all the settings you can edit with an OS X native install.

Albertina answered 6/3, 2014 at 17:10 Comment(0)
K
0

I needed to configure Jenkins on a CentOS box via Puppet using the rtyler/jenkins module. Looking through the module code might suggest that HTTP_PORT and PREFIX should be the parameters in the config_hash but this did not work for me. What worked for me was something like the following Puppet configuration:

  class { 'jenkins':
    config_hash  => { 
       'JENKINS_PORT' => { 'value' => '8085' },
       'JENKINS_ARGS' => { 'value' => '--prefix=/jenkins' },
    },
  }

I was able to confirm that this updated the contents of "/etc/sysconfig/jenkins" (I believe this is the CentOS/RedHat file location).

Kep answered 28/3, 2018 at 7:47 Comment(0)
B
0

For a Windows installation add the prefix within the <arguments> tag (jenkins.xml) and restart the service (Powershell Restart-Service jenkins). E.g.:

  <executable>%BASE%\jre\bin\java</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war" --prefix=/jenkins</arguments>
Becky answered 28/12, 2018 at 12:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.