'Make Jenkins Listen at host/jenkins
Can we have Jenkins server to be listened at example.com/jenkins?
If I can achieve this, I can do path based routing in ALB & do some cost savings.
Let me know if we can achieve this.
Solution 1:[1]
- To start Jenkins under a specific path, use the --prefix flag at startup.
E.g.:
--prefix=/jenkins
See: https://www.jenkins.io/doc/book/installing/initial-settings/
- To access Jenkins at example.com/jenkins, set up an AWS ALB with a target group config pointing to port 8080 and /jenkins as path.
When you configure ALB to mask the port 8080, you also have to set the Jenkins URL correctly to point to example.com/jenkins in the global settings.
Back then I've done this with Groovy on startup:
import jenkins.model.*
JenkinsLocationConfiguration location = jenkins.getExtensionList(jenkins.model.JenkinsLocationConfiguration).get(0)
try {
location.setUrl("http://example.com/jenkins")
} catch (MissingMethodException e) {
logger.severe("+++++++++++++++++++++ Error setting Jenkins URL! +++++++++++++++++++++++++")
jenkins.doSafeExit(null)
System.exit(1)
}
See: https://www.jenkins.io/doc/book/managing/groovy-hook-scripts/
But meanwhile there may be better solutions like Config as Code Plugin.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Franco Arendholz |
