我正在尝试pom.xml
使用groovy脚本替换测试。这是我的两种方法。该文本应替换为{env.AM_$environment.toUpperCase()_SERVER_CREDS_USR}
方法一
File mainPomXml = new File(rootDir,'/pom.xml')
mainPomXml.text.replace('{env.AM_$environment.toUpperCase()_SERVER_CREDS_USR}','${env.AM_$environment.toUpperCase()_SERVER_CREDS_USR}');
方法二
def mainPomXml = new File(rootDir,'/pom.xml')
def mainPom = mainPomXml.text.replace('{env.AM_$environment.toUpperCase()_SERVER_CREDS_USR}','${env.AM_$environment.toUpperCase()_SERVER_CREDS_USR}');
mainPomXml.write(mainPom);
但是这些方法都不起作用。这意味着两个都执行,但是测试不会被替换。如何解决这个问题?
如下更改mainPom部分。
def mainPomXml = new File(rootDir, '/pom.xml')
def mainPom = mainPomXml.text.replace('AM_SERVER_CREDS_USR', '${env.AM_'+ env.toUpperCase() +'_SERVER_CREDS_USR}')
mainPomXml.write(mainPom)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句