简体   繁体   中英

Will below command work as it as on jenkins for running my jar file with command line arguments?

I have built an executable jar file which is also a standalone SpringBoot Application. The requirement is that I have to run this jar file from command line which also provides command line arguments which are meant to override application.properties properties and will be used further. I have tried and this works perfectly when ran from Windows Command Prompt.

Now I further want to deploy this on jenkins and run the same jar file usign jenkins using the command:Note that the command is important since it overrides application.properties.

Will it work in jenkins? Should i go with "Execute Shell" or "Execute Windows batch command" for it in jenkins? I would be trying it but need o know.

Command: java -jar myJArName.jar --server.port=10 --another.argument=1 --another.argument=2

Yes, you can use execute shell as you mentioned above if :

  • Java is installed on the host that Jenkins runs on
  • java is part of $PATH (you can check this by running which java on your jenkins host)
  • myJarName.jar is actually on the host jenkins runs on

Btw. I assume Jenkins runs on a Linux host. Otherwise you might have to use Execute Windows batch command which will work in a similar way to execute shell , but I never used it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM