[英]Jenkins - Execute shell commands with wildcards
我試圖讓Jenkins執行shell命令,但仍然允許使用通配符。 這是我正在嘗試做的參考:
mvn deploy:deploy-file -Dpackaging=jar -DrepositoryId=snapshots -Durl=http://nexus.example.net/content/repositories/snapshots -DpomFile=Spigot/Spigot-Server/pom.xml -Dfile=Spigot/Spigot-Server/target/spigot-*.jar
我需要能夠通過上面的命令部署這個jar,因為該項目的git存儲庫不是由我擁有或操作的,所以我需要能夠將它直接部署到我自己的Nexus實例。 為了確保它將支持編譯jar的所有可能版本,我必須使用外卡。 不幸的是,當Jenkins嘗試執行命令時,它會逐字地采用通配符。 我真的不知道如何解決這個問題,我將不勝感激。 謝謝!
如果它是一個簡單的單個.jar文件,請嘗試:
mvn deploy:deploy-file -Dpackaging=jar -DrepositoryId=snapshots -Durl=http://nexus.example.net/content/repositories/snapshots -DpomFile=Spigot/Spigot-Server/pom.xml -Dfile=$(find Spigot/Spigot-Server/target/ -name 'spigot-*.jar')
如果它是多個文件,那就有點復雜了:
當您想要在同一個 (groupId,artifactId,version)下部署多個工件時,使用maven deploy-file參數文件 , 分類器和類型 - 例如.jar和-sources.jar
即使對於那個用例,語法也有些違反直覺 - 你必須使用file = file1.jar作為第一個工件 ,然后使用files = file1-sources.jar,file1-test-sources.zip,.. 其余的 ,同時使用分類器/分類器 (和包裝/類型 )以相同的方式(位置)指定要上載的每個工件的分類器/類型。
如果您的用例是上載不同版本的工件 ,則需要為每個版本執行一次maven部署文件調用 。
您也可以考慮一些替代方案:
(取決於有多少工件,以及新工件的頻率) - 將這些工件手動上傳到Nexus
讓Nexus 代理另一個為這些工件提供服務的Nexus存儲庫 。
如果你的意思是你只想直接傳遞*
,只需使用單引號來避免shell應用globbing:
mvn deploy:deploy-file [...] '-Dfile=Spigot/Spigot-Server/target/spigot-*.jar'
如果您嘗試部署多個文件,我認為問題不在於Jenkins或bash命令,而在於使用Maven Deploy Plugin 。
文檔說明
file File - File to be deployed. User property is: file.
如果你要部署額外的工件,請使用
files String - A comma separated list of files for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries in types or classifiers, then an error will be raised. User property is: files.
因此,如果您指定額外的文件以通過使用其他files
, types
, classifies
參數,明確部署,將會更好。
... -Dfile=Spigot/Spigot-Server/target/main-spigot.jar \
-Dfiles=$(ls -1d Spigot/Spigot-Server/target/spigot-*.jar | paste -sd ,) -Dtypes=... -Dclassifiers=...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.