1

simple question for you..

I have a property file with a value like this

 CommercialManager=MOT
 CommercialUser=AT
 CommercialAdmin=POT

I'm calling an Ant Script from Jenkins, passing some variables.. some of these variables are used to get a dynamic property from the property file..

I'm saying that if i select into the jenkins job the CommercialAdmin variable from a select list i want to get the property with that name.

The value selected into the Jenkins JOB is set inside a variable ROLE, that is passed to my ANT script..

Below my code:

<property file="Profiles.properties" prefix="profiles"/>

<echo>${profiles.CommercialManager}</echo> 

Doing like this everything works fine, it prints out MOT But as you can see the value is not dynamic, is not the one taken from jenkins job..

So i should do something like this:

<echo>${ROLE}</echo>

But if I do something like this, the print returns the value of the property ROLE that is:

profiles.CommercialManager

and not the value taken from the properties file..

How can i manage this? I think its easy but, its late, and i swimming into a sea of confusion..

Thanks a lot!

ivoruJavaBoy
  • 1,307
  • 2
  • 19
  • 39

1 Answers1

1

There are a number of ways to dynamically get a property value from a variable described in other threads:

Personally, I would use javascript:

<property file="Profiles.properties" prefix="profiles"/>

<script language="javascript"><![CDATA[
    project.setProperty("CommercialManager", project.getProperty("${Role}"))
]]>
</script>

<echo>${CommercialManager}</echo>
Community
  • 1
  • 1
TheEllis
  • 1,666
  • 11
  • 18