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?
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.
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.
Related
I would like to add this to my .bazelrc, but the $(whoami) doesn't expand like if it was in a shell.
startup --output_user_root=/tmp/bazel/out/$(whoami)
It produces the literal result:
/tmp/bazel/out/$(whoami)/faedb999bdce730c9c495251de1ca1a4/execroot/__main__/bazel-out/
Is there any way to do what I want: adding a name/hash to the option in the .bashrc file?
Edit: what I really want is to set the outputRoot to /tmp/bazel/out without using an environment variable and to let bazel create it's user and workspace hash directories there.
You can run Bazel from a wrapper script. In fact, that's exactly what the bazel binary is (at least on Linux): it's a wrapper script that calls bazel-real. You can edit this wrapper script if you like, or rename it to bazel.sh and write your own wrapper.
/usr/bin/bazel is a script which looks for //tools/bazel, and if it exists, calls it. Otherwise, it calls bazel-real. This lets you check Bazel into your repo, or otherwise modify how it gets called. We use that to download a specific version of bazel, extract it, and then call it.
I would recommend creating //tools/bazel, and having that do your modification. It can then either call a versioned version of bazel, or call bazel-real. That keeps your modifications local to your repo rather than global.
I am having troubles to force Jenkins job to always run with default parameter. Does anyone know the possible plugin to help with that case? Right now I am using extended parameter choice, but still there is no option to just run the job with default value without asking user for parameter.
Solution 1
Currently there is not a straight forward solution to run a parameterized job with default parameter using a plugin. However there is a workaround to accomplish that using the EnvInject Plugin.
As #General_Code noted:
Just add the build step, set the variable like: var1=value and then
use it using ${var1}
Solution 2
As #RejeeshChandran noted:
a more robust solution is the Parameterized Build Plugin which provides the functionality of defaults values for the parameters.
Note
Note that Parameter Defaults Options is a plugin under development which will solve exactly this request. When it is released, you will be able to set it up so your parameter will get a default value when you run it manually.
you can use this plugin Parameterized Scheduler
allow you to write a cron expression with the parameters inside like this
H(0-29)/10 * * * * % name=value; othername=othervalue
Documentations
Use This build is parameterized option in Jenkins configuration. Here you can add default values to the parameters. It will run with default value if the user doesn't change it. It is good to have configurable parameter before running the job.
For configuration details see https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build. You can have multiple parameters.
Go to your jenkins job -> Configure -> General Tab
Add all options in "Description" but the default option in "Default Value"
enter image description here
I'm using TFS2015 update 1. I want to pass information from one build step to the next, how is this possible?
That seems like a very simple task, but I can't figure out how that's suppose to work. Passing a variable to a build step is easy, but passing information from one step to the next seems to be impossible. I hope I'm wrong.
You can call the task.setvariable Logging Command, which sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable.
Example:
##vso[task.setvariable variable=testvar;]testvalue
I am setting up a parameterized build on my Jenkins server.
Basically I want to have the git branch name as a parameter. Then I want to use that parameter in various other fields in the job config.
I don't know if this is even possible, but I hope that it might be as it seems an obvious need.
The only docs I could find is this old wiki page
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build
It shows that build parameter is available as an ENV var, but it doesn't show how to use it elsewhere in the job config.
despite being undocumented, this syntax works in job config fields
${PARAM_NAME}
Just use $PARAM_NAME anywhere in the configure.
The easiest way is to use the "Git parameter" parameter type in your config and then you can reference that simply in the Source Code Management section - see here. This assumes that the Jenkins instance has the Git parameter plugin installed.
If you don't have that option, then:
you can simply add a String parameter to the configuration and use that in you configuration, but you need to uncheck "Lightweight checkout" to avoid errors like this:
stderr: fatal: Couldn't find remote ref refs/heads/${BRANCH}
String parameter declaration:
String parameter usage:
Source of pictures
How can I make generic parameters in jenkins that will be updated automatically for example I want to be able to create a parameter which hold today's date and it will be update automatically and not manually ?
thanks!
You might want to use EnvInject.
Setup your job and then add a build step "Inject envornment variables" from a file with an absolute path or the path relative to current job's workspace, which will contain something like:
DATE_VARIABLE="20150708"
OTHER_OPTIONAL_VARIABLE="value"
In previous execute shell step you may for example do:
echo "DATE_VARIABLE="`date +"%d%m%Y"` > env_inject.txt
After all that you don't need Parameters for a build, since you will have the needed parameter injected as an environment variable.