大佬教程收集整理的这篇文章主要介绍了在 jenkins 管道 shell 命令中传递 maven 参数,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我对以下问题有疑问,有人可以帮我解决这个问题。
我想从 jenkins 管道中的 shell 传递 maven pom.xml 属性,该属性需要被 maven 而不是 groovy 或 shell 替换。
示例:
pipeline {
agent any
stages {
stage('build') {
steps {
sh 'mvn -Doracle.db.url=${db.url} package'
}
}
}
}
此处 ${db.url} 应该由 maven setting.xml 文件属性中的 url 代替,而不是由 Jenkins 管道中的 groovy 或 shell 代替。 我尝试了不同的组合,但它在 Jenkins 管道中给了我错误。
如果上面的 maven 属性是常量(一些常量 url),那么它很容易传递,但是当我想传递任何可变属性(${db.url})时,我无法使用任何语法来实现。
如果你想让 maven 评估 ${db.url}
,它必须像
pipeline {
agent any
stages {
stage('build') {
steps {
sh 'mvn -Doracle.db.url=\\${db.url} package'
}
}
}
}
现在如果你看到,Jenkins会像这样准备maven命令-
如果你不转义它会给你Bad substitution
错误
以上是大佬教程为你收集整理的在 jenkins 管道 shell 命令中传递 maven 参数全部内容,希望文章能够帮你解决在 jenkins 管道 shell 命令中传递 maven 参数所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。