I am trying to get Jenkins to execute a shell command but still allow wildcards to be used. Here's what I'm trying to do for reference:
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
I need to be able to deploy this jar through the above command because the git repository for that project isn't owned or operated by me, so I need to be able to deploy it directly to my own Nexus instance. In order to ensure that it will support all possible versions of the compiled jar, I must use a wild card. Unfortunately, when Jenkins tries to execute the command, it takes the wildcard literally. I'm really not sure how to solve this, I would appreciate any help you can provide. Thank you!
If it's a simple single .jar file try this:
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')
If it's multiple files, it's a bit more complicated:
The maven deploy-file parameters files, classifiers and types are used when you want to deploy multiple artifacts under the same (groupId, artifactId, version) - for example a .jar and -sources.jar
Even for that use case, the syntax is somewhat counterintuitive - you must use file=file1.jar for the first artifact, and then files=file1-sources.jar,file1-test-sources.zip,.. for the rest, while using classifier/classifiers (and packaging/types) in the same way (positional) to specify classifier/type of each artifact you are uploading.
If your use case is uploading artifacts of different versions, you will need to do one maven deploy-file call for each version.
You also might consider some alternatives:
(depending on how many artifacts, and how often new ones will come) - upload these artifacts manually to Nexus
Make you Nexus proxy another Nexus repository that serves these artifacts.
If you mean you just want the *
to be passed on directly, just use single quotes to avoid the shell from applying globbing:
mvn deploy:deploy-file [...] '-Dfile=Spigot/Spigot-Server/target/spigot-*.jar'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With