持续集成 [求助] dubbo testNG mavne jenkins 如何动态传递测试环境参数至 customer.xml 中的 ZK 地址

Kelvin.Ye · 2017年02月15日 · 最后由 CC 回复于 2017年02月16日 · 1211 次阅读

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

共收到 3 条回复 时间 点赞

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

<plugin>
  <groupId>com.alibaba.maven.plugins</groupId>
    <artifactId>maven-autoconf-plugin</artifactId>
    <version>0.3-alpha-8</version>
    <executions>
        <execution>
            <phase>process-resources</phase>
            <goals>
                <goal>config</goal>
            </goals>
        </execution>
    </executions>
</plugin>

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

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

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

#2 楼 @yekw713 你这种方式配置文件是写在项目工程里面,后期发到多个测试环境,没有通用型😃

—— 来自 TesterHome 官方 安卓客户端

Kelvin.Ye 关闭了讨论 03月03日 11:30
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册