亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何共享/傳遞具有應用程序屬性和 pom 文件的變量

如何共享/傳遞具有應用程序屬性和 pom 文件的變量

米琪卡哇伊 2021-08-04 09:53:29
我有一個多模塊 spring-boot 項目,在我的應用程序的集成測試之前,我啟動了另一個子模塊(它是由另一個 spring boot 應用程序制作的存根)你可以看到它附加到“預集成測試”,它是最后工作正常。 Parent Pom|   |----myRealApp module(spring boot app)|----stub module(This is also a spring-boot app)我的問題是,有沒有辦法隨機化并共享此端口(未固定為 8090),因此 Jenkins 服務器上的并發構建可以運行測試并且不會失敗,因為地址已在使用中。我知道我可以在 spring 屬性文件中生成隨機數/端口。但是找不到將其傳遞給 Pom 的方法。application-test.properties myRealApp的: stub.port=8090 stub.url=http://localhost:${stub.port}/stub/api/v1/domains/myRealApp 的 Pom:      <plugin>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-maven-plugin</artifactId>            <configuration>                <mainClass>${spring.boot.mainclass}</mainClass>            </configuration>            <executions>                <execution>                    <id>start-stub</id>                    <configuration>                        <arguments>                            <argument>--server.port=8090</argument>                        </arguments>                        <mainClass>io.swagger.Stub</mainClass>                        <classesDirectory>../my-stub/target/classes</classesDirectory>                    </configuration>                    <goals>                        <goal>start</goal>                    </goals>                    <phase>pre-integration-test</phase>                </execution>                <execution>                    <goals>                        <goal>build-info</goal>                    </goals>                </execution>            </executions>      </plugin>
查看完整描述

2 回答

?
ITMISS

TA貢獻1871條經驗 獲得超8個贊

你可以通過 jenkins Port Allocator Plugin做到這一點

分配端口后(可以說HTTP_PORT),然后您可以將其作為命令行傳遞

-Dstub.port=$HTTP_PORT


查看完整回答
反對 回復 2021-08-04
  • 2 回答
  • 0 關注
  • 238 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號