Seed Job environment variable ${WORKSPACE} is assigned to child jobs - jenkins

Create a Seed Job using DSL that would create 5 Child Jobs. As part of build step I've to use ${WORKSPACE} environment variable, which should read the value from the slave machine where the child Job is running. But however when the child jobs are created, the workspace value is replaced with SeedJobs workspace location from master server.
How would I restrict seed job not to inject its ${WORKSPACE} value.
Could some one help me on this please.
Thanks
Mano

To refer to the BUILD_NUMBER of the generated job in your job-dsl code, you should code it as follows :
"\${BUILD_NUMBER}"
The important part is the \ before the $ sign which prevents the evaluation of the BUILD_NUMBER variable as it pertains to the Goovy runtime that is (likely) your Jenkins job-dsl seed job.
The config.xml of the generated job will contain ${BUILD_NUMBER} instead of a digit that represents you build number of your seed-job. And then your generated job will evaluate that when it runs.

Related

Jenkins CHANGES_SINCE_LAST_SUCCESS plugin variable is empty

I have installed the Changes Since Last Success Plugin for Jenkins jobs. Inside the Build step of a Jenkins job I am trying to echo the value of the CHANGES_SINCE_LAST_SUCCESS variable. Unfortunately there is no value for this variable. I echo this value into a file inside my job's workspace.
You need Email-ext plugin instead.
Changes Since Last Success plugin has nothing to do with the CHANGES_SINCE_LAST_SUCCESS variable.
https://wiki.jenkins.io/display/JENKINS/Changes+Since+Last+Success+Plugin
This plugin adds a build action to aggregate changes from all previous builds to the last successful one. The primary goal is to generate a changelog to be used for continuous delivery, as an aggregate for all changes since the last deployable artifact.
Additionally, this plugin can be used to generate a changelog for an arbitrary range of builds:...

choosing which job will execute in multijob phase, from env variable, in jenkins

I have a multijob, and I want at phase jobs, at job name, to select the actual job name, from a variable, and more specific from an environmental variable.
I tried, among many other things, the following:
This should have been working, because I cross checked that $JOB exist and with a value at $WORKSPACE?build.properties.
Any ideas?
jenkins version is 2.73.3

Jenkins Multijob - pass project name parameter from Build_job1 to Deploy_job2

on a multi job I have two phases:
PhaseA running Build_job1, with a project name Build_job1, pulling stuff from git to dir: /var/lib/jenkins/workspace/Build_job1
PhaseB running Deploy_job2, that rsyncs /var/lib/jenkins/workspace/Build_job1/* to a bunch of servers.
For internal reasons I need to replicate the multijob, the build job and the deploy job to different environments (PROD, QA, Staging). I each case, the deploy job rsync will need to copy files from a different build directory (Build_QA, Build_Prod, Build_whatever etc.).
As Jenkins creates the dir per project name, I need the rsync command in the deploy job to get the project name as a parameter that is passed down from the build job.
help?
Are you wanting to pass down the current job's project name down to its children? If so, you can pass down this information via a Jenkins Set Environment Variables call "JOB_NAME" in conjunction with a predefined job parameter. For example, something like:
Param1=${JOB_NAME}
If the Multijob job name is "QA", you can pass that down to both the build and deploy phase jobs via a predefined parameter and then construct the final "Build_QA" path by doing something like "Build_${Param1}" or "Build_%Param1%".

Jenkins Promoted Build Parameter Value

I have a jenkins job that runs some tests and promotes the build if all tests pass.
I then have a second job that has a 'Promoted build parameter' which is used for deployments.
THe idea is that the deply job should let you pick one of the prompted builds for deploying. The issue I'm having is that I can pick a promoted build, but I have not idea how I access information about the build.
I've named the build parameter
SELECTED_BUILD
And according to the docs this should then be available via the environment.
The problem is that it doesn't seem to be bound to anything.
If I run a build step to exectute this sheel script:
echo $SELECTED_BUILD
echo ${SELECTED_BUILD}
The values are not interpolated / set.
Any idea how I can access the values of this param?
Many Thanks,
Vackar
Inject the information as variable user jenkins plugin (eject evn variable).
while triggering parameterized build on other job, pass above variable as parameter to next job.

Updating jenkins job variable

Parameterized variable are not getting updated in jenkins
I m using the conditional build-step plugin to update the jenkins job parameter by executing shell script its showing me the new value of variable as well but its not get reflected.
You can try the EnvInject Plugin. One of the features is a build step that allows you to "inject" parameters into the build job from a settings file.
Create a property for the email list in the env.properties file:
echo "variable=`value`"> env.properties
It will create the properties file in the job workspace directory.
env.properties
In shell script:
"$variable"
If I understand correctly, you are trying to change the value of a pre-defined parameter
from within a script that is run by the job.
This will not work, because of "scope" (or "call-stack"),
as a process (your script) cannot change the environment of a parent process (your Jenkins job).

Resources