tintin
tintin

Reputation: 5867

How to pass parameter to Jenkins service

I have a Jenkins service which I run like sudo service jenkins start|stop. Now, I want to pass a parameter --prefix=/jenkins to this service. I tried sudo service jenkins --prefix=/jenkins but this param is ignored. How can I pass this additional param?

Upvotes: 0

Views: 3094

Answers (2)

Alex O
Alex O

Reputation: 8164

You need to extend your init script. According to the service manual page,

service passes COMMAND and OPTIONS it to the init script unmodified

It depends on your distribution, but most likely your init script does not handle any additional options. If you fix that, then you will be able to pass parameters.

Having said this, the proper way to establish settings in a more permanent way is the one described by Jon S.

Upvotes: 0

Jon S
Jon S

Reputation: 16346

You should edit /etc/default/jenkins. The quick and dirty way is to find the variable JENKINS_ARGS="..." at the end of the file. Simply add --prefix=/jenkins there.

Let's say that you had:

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

it should be:

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

The nice way is to edit the variable PREFIX which should be located a few lines above, in my case it was PREFIX=/$NAME, change that to PREFIX=/jenkins and then, similar to before, you edit JENKINS_ARGS and add --prefix=$PREFIX.

Upvotes: 2

Related Questions