51Testing软件测试论坛

标题: [求助] dubbo testNG mavne jenkins 如何动态传递测试环境参数至 customer.xml 中... [打印本页]

作者: 八戒你干嘛    时间: 2017-6-15 14:07
标题: [求助] dubbo testNG mavne jenkins 如何动态传递测试环境参数至 customer.xml 中...
本帖最后由 八戒你干嘛 于 2017-6-15 14:09 编辑

目标是实现由jenkins选择测试环境,比如test1,test2,
jenkins传值至maven-surefire-plugin的systemPropertyVariables,
然后问题是如何再即时动态修改dubbo配置文件的customer.xml中的
或者各位大神有更好的解决方案?

作者: 悠悠小仙仙    时间: 2017-6-15 14:21


使用maven的autoconf方式解决
在pom.xml中增加

  1. <plugin>
  2.   <groupId>com.alibaba.maven.plugins</groupId>
  3.     <artifactId>maven-autoconf-plugin</artifactId>
  4.     <version>0.3-alpha-8</version>
  5.     <executions>
  6.         <execution>
  7.             <phase>process-resources</phase>
  8.             <goals>
  9.                 <goal>config</goal>
  10.             </goals>
  11.         </execution>
  12.     </executions>
  13. </plugin>
复制代码


再配置auto-config.xml(存放路径:resources/META-INF/autoconf/)
配置好你要的testEnv地址;
在你想编译的目录下,随便写个xx.properties配置文件,配置文件中写着你想要的testEnv地址

编译的时候指定这个xx.properties文件即可
mvn clean package -DuserProp=xx.properties
作者: 悠悠小仙仙    时间: 2017-6-15 14:24


使用maven的autoconf方式解决
在pom.xml中增加

  1. <plugin>
  2.   <groupId>com.alibaba.maven.plugins</groupId>
  3.     <artifactId>maven-autoconf-plugin</artifactId>
  4.     <version>0.3-alpha-8</version>
  5.     <executions>
  6.         <execution>
  7.             <phase>process-resources</phase>
  8.             <goals>
  9.                 <goal>config</goal>
  10.             </goals>
  11.         </execution>
  12.     </executions>
  13. </plugin>
复制代码


再配置auto-config.xml(存放路径:resources/META-INF/autoconf/)
配置好你要的testEnv地址;
在你想编译的目录下,随便写个xx.properties配置文件,配置文件中写着你想要的testEnv地址

编译的时候指定这个xx.properties文件即可
mvn clean package -DuserProp=xx.properties

作者: 八戒你干嘛    时间: 2017-6-15 14:27
悠悠小仙仙 发表于 2017-6-15 14:24
使用maven的autoconf方式解决
在pom.xml中增加

谢谢回复,用xx.properties过渡,再在dubbo_customer.xml读取properties的值解决了




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2