2017-02-24 77 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")