0

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.

Arvin
  • 315
  • 1
  • 3
  • 15
  • For the ${url}/jenkins portion, you want tobstart with [`--prefix=${PREFIX}`](https://www.jenkins.io/doc/book/installing/initial-settings/). You would probaly alao have to run on different port; see options. – Ian W Feb 16 '21 at 02:11

1 Answers1

0
  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/

  1. 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.

Franco
  • 193
  • 1
  • 9