2017-02-24 38 views
0

请阅读注释以了解问题。如何在Jenkins Groovy中获得动态属性DSL

job(buildV2PerfTest) { 
    displayName('Performance Test') 
    steps { 

     //I am loading a value into a properties file using the shell command. The name of the variable is callbackUrl 
     shell('echo "callbackUrl=http://`curl http://169.254.169.254/latest/meta-data/public-hostname`:8080" > env.properties') 

     //then I add the propeties file to Jenkins properties 
     environmentVariables { 
      propertiesFile('env.properties') 
     } 
     maven { 
      goals('-P performance test') 
      //I want to pass to maven a loaded property here 
      property('callbackUrl', "${callbackUrl}") 
     } 
    } 
} 

的问题是,当我编译的代码,它说的是,属性不存在。确实。它会在我触发这项工作时存在。我想知道如何引用动态属性。

P.S. 的documentation讲述如何加载变量,但未能在解释如何访问它们

+0

你试过'build.environment.get(“callbackUrl”)'? –

回答

0

的解决方案是:

property('callbackUrl', "\$callbackUrl")