繁体   English   中英

如何在Jenkins Groovy DSL中获得动态属性

[英]How to get a dynamic property in 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}")
        }
    }
}

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

PS该文档介绍了如何加载变量,但未能解释如何访问变量

解决方案是:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM