Retrieving BuildDef properties in ANT using RTC Build Agent
I.E.
${env.userId}
Is there a way to get the values without using the "env" prefix. What I really want is to be able to use the same property name as defined in the Builddef without have to use a prefix. In our product we have ant tasks already defined and in use for our customer base. What I want to do is to be able to drive it using the RTC Build & BuildDef, but I need to be able to retrieve the properties by the same names.
IS there some way to configure the build agent not to use env as a prefix on properties?
-Steve
One answer
Comments
Or the mapping could be done in the Ant script itself, e.g.
Nick, thanks for the feedback and suggestion. Currently I do:
ant -f ${zbuildPath}/zBuildAntRBA.xml -lib ${zbuildPath} -lib ${buildSystemPath}/buildtoolkit
defined as the BuildDef command parm. We have many properties for a specific build type though 20+, so it becomes tedious and a service complication, which we are trying to avoid having to do. It would be nice if the BFA had a way to write to a properties file like the JBE. That would really help and keep things simple.
-Steve
Nick, I'm also attempting to integrate Jenkins with our Build tool. I'm following the scenario https://jazz.net/wiki/bin/view/Main/JazzScmWithJenkins which appears you were involved.
My question is, Are properties defined in the RTC BuildDef passed to the ANT task that is defined in the Jenkins Project Build Invoke Ant or must all properties be defined in Jenkins Build Invoke Ant properties section?
-Steve
properties in the build job and build def are not passed all the way thru to the ant job (as env variables)..
this is why I use the ant properties file (on the ant tab of the build definition) and load them in my ant task. (see comment 1 to original question)
There is no Ant tab or field to write props to a file via the RTC BuildDef for Jenkins, so that solution is not possible. It seems to me that properties defined in the RTC BuildDef would be passed to Jenkins in some form, but apparently they are not. I tested this and indeed the properties are not available in the Jenkins Build Ant script. Seems to me if RTC is integrated to work with Jenkins that properties defined in the RTC BuildDef would be passed; otherwise why have the propeties tab in the RTC BuildDef for Jenkins.
I was able to pass RTC BuildDef properties into the Jenkins Ant task by also defining the property as a Build parameter in the Jenkins Project. This is a duplication of effort and a serviceability concern to have to keep both in sync.
What I found is when I submit the build for RTC it modifies the Jenkins project to be a Parametrized build and adds the buildResultUUID as a parm. Even if I delete that parm it readds it on the next RTC Build request. It doesn't add it if I build form Jenkins. Therefore I have to ask why doesn't the RTC Jenkins integration do that for all the properties defined in the RTC BuildDef and Build Engine? That would allow the user to only have to define properties in RTC.
We are fairly limited here by the Jenkins REST API. AFAICT, there's no way to pass a set of properties in one go, as a properties file, so they need to all be defined as parameters. When we added buildResultUUID (needed for sync to RTC build result) it was unclear that we should sync all properties, e.g. if using Jenkins plugin or JBE to run the SCM phase of the build, it pulls the SCM config properties from the build request.
Comments
sam detweiler
Aug 05 '14, 2:59 p.m.in the build definition, ant tab, last field, tell it to write all the properties to a file..
(I use filename 'all.properties')
then load that file in your build.xml
here is how i do that in my build file
<target name="load-props" if="./all.properties">
<loadproperties srcFile="./all.properties"/>
</target>
Steve White
Aug 05 '14, 3:36 p.m.Thanks, but I am using the cmd line Rational Build agent whihc does not include the ANT tab like the ANT JBE. There is not feature to write properties to a file that I can find.
The reason I have to prefix with "env" is becuase the build.xml uses
<property environment="env"/> to access the environment variables, which the Builddef & engine properties are set. I'm looking for a way to access these properties without using a prefix.