Here's how I do it using the "build-name-setter" and "Post_build_task" plugins:
The "build-name-setter" plugin can read a value from a property file in the
workspace. It reads it twice during a job run; first before any build tasks
are executed, then again after all build tasks complete successfully. My ant
build generates our desired build name and writes it to a file named
"version.properties" in the form "product.version=ACME-1.0_0052". That
version.properties file actually gets used for our solaris packaging, but I
have a build step that copies it to the jenkins workspace so that I can also
use it to set the build name in jenkins so they match.
1. Configure build-name-setter to read a property file. "Build Name" field
should have the following:
${PROPFILE,file="version.properties",property="product.version"}
NOTE: The first time you run the job, the version.properties file will not yet
exist in the workspace, so the job will fail since it can't find the file. No
big deal since you will have a post-build task that will then create one for
you (explained later). If you don't want the first build to fail because of
this, simply create the version.properties file in the workspace (on every node
it can run on) ahead of time with this: "product.version=BUILD_IN_PROGRESS".
I've intended to try to find a plugin that can create the file in the workspace
before the build-name-setter runs, but it hasn't been a high enough priority
for me yet. ;-)
2. After my ant build step, I created a build step that simply copies the
version.properties file (generated from my ant build) to the ${WORKSPACE}. The
build-name-setter will read that file again after all build steps complete
successfully and set the build name. Note that if any build steps fail, the
build name will remain "BUILD_IN_PROGRESS" (pros and cons to that).
3. Create a "Post build task" that will change the value of the
"product.version" property back to "BUILD_IN_PROGRESS" for the next build.
Log text field: version.properties
Script: echo product.version=BUILD_IN_PROGRESS >
${WORKSPACE}/version.properties
-Jeff Ng
From: [email protected]
[mailto:[email protected]] On Behalf Of Umesh Padhye
Sent: Wednesday, March 20, 2013 8:07 AM
To: [email protected]
Subject: EXTERNAL: Build name setting
Hello,
Below is my requirement.
I am grabbing build date info from a text file for my application and I want to
set that as build name in Jenkins.
I tried approach of env var as build name.
I was running few batch files to extract build info from text file and setting
them as env var.
But Jenkins nodes (one as win service and another as web slave agent) only
recognize that env var if I reboot the system and nodes are relaunched.
I want basically build name to be set dynamically checking the text file
content continuously.
Please help me how to achieve this.
Umesh
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.