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

Time:12-02

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

CodePudding user response:

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.

  • Related