How to add Jenkins command line options to CloudBees CI (CloudBees Core)?

Article ID:360039596731
2 minute readKnowledge base

Issue

  • Don’t know how to add/update Jenkins command line options to CloudBees Core or Jenkins

Resolution

It depends on the way you ran Jenkins.

The following links document some of the options. However, the way to learn the options that apply to your version of the product is to use the --help command line option, e.g. java -jar jenkins.war --help.

Traditional Platform

Running Jenkins inside Jetty Winstone container

This is the default way to run Jenkins if you installed Jenkins using system packages.

To pass command line options to Jenkins, you need to change the Jenkins service configuration file. You might require elevated privileges to be able to modify this file.

Please read the service config file carefully since they expose some of the features controlled by command line options via the simple variables, e.g., HTTP[S]_PORT, HTTPS_KEYSTORE, etc.

In CloudBees Core on traditional platforms - Operations Center, you can find this file under:

  • /etc/default/cloudbees-core-oc: location for most of the Linux distributions.

  • /etc/sysconfig/cloudbees-core-oc: location for RedHat/CentOS distribution.

  • C:\Program Files\CloudBeesCoreOC\jenkins.xml: default location for Windows.

In CloudBees Core on traditional platforms - Client controller, you can find this file under:

  • /etc/default/cloudbees-core-cm: location for most of the Linux distributions.

  • /etc/sysconfig/cloudbees-core-cm: location for RedHat/CentOS distribution.

  • C:\Program Files\CloudBeesCoreCM\jenkins.xml: default location for Windows.

In CloudBees Jenkins Distribution, you can find this file under:

  • /etc/default/cloudbees-jenkins-distribution: location for most of the Linux distributions.

  • /etc/sysconfig/cloudbees-jenkins-distribution: location for RedHat/CentOS distribution.

  • C:\Program Files\CloudBeesJenkinsDistribution\jenkins.xml: default location for Windows.

In Jenkins LTS and in CloudBees Jenkins Platform - Client controller, you can find this file under:

  • /etc/default/jenkins: location for most of the Linux distributions.

  • /etc/sysconfig/jenkins: location for RedHat/CentOS distribution.

  • C:\Program Files\Jenkins\jenkins.xml: default location for Windows.

In CloudBees Jenkins Platform - Operations Center, you can find this file under:

  • /etc/default/jenkins-oc: location for most of the Linux distributions.

  • /etc/sysconfig/jenkins-oc: location for RedHat/CentOS distribution.

  • C:\Program Files\JenkinsOC\jenkins.xml: default location for Windows.

Debian / Ubuntu based Linux distributions

In your service configuration file, look for the argument JENKINS_ARGS. It should look something like this:

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"

Then, add the arguments:

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --pluginroot=/var/cache/$NAME/plugin --httpPort=$HTTP_PORT"

RedHat Linux based distributions

In your service configuration file, look for the argument JENKINS_ARGS. It should look something like this:

JENKINS_ARGS=""

Then, add the arguments:

JENKINS_ARGS="--pluginroot=/var/cache/jenkins/plugin"

Running Jenkins in Windows as a Service

In your service configuration file, add the arguments into the <arguments> tag. It should look like this:

<arguments>-Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --pluginroot=/var/cache/jenkins/plugin</arguments>

Running Jenkins inside Docker

The JENKINS_OPTS should be passed to the container via --env JENKINS_OPTS="..." like the following:

docker run --name myjenkins -p 8080:8080 -p 50000:50000 --env JENKINS_OPTS="--prefix=/jenkins" jenkins/jenkins:lts

Modern Platform

Operation Center

You need to add the Jenkins command line option you would like to set OperationsCenter.JenkinsOpts (e.g., --set OperationsCenter.JenkinsOpts).

Managed controllers

Go to the operations center Dashboard and click on Configure on the Managed controller you want to add the Jenkins command line option.

mmconfiguration

Once here, you can add your Jenkins command line options under Provisioning > Jenkins Command Line arguments.

In case you would like to make the new Java argument directly applicable for all new Managed controllers created, instead of applying it one by one, you can go under the operations center to Manage Jenkins -> Configure System -> Kubernetes controller Provisioning [Advanced] -> Default Jenkins Command Line arguments and add the Jenkins command line options there.