brain storm
brain storm

Reputation: 31272

Remove version from war to be deployed to Tomcat?

My Gradle build generates artifacts as following:

MyAppService-1.2.038.war.

I do no want to access localhost:8080/MyAppSservice-1.2.038 but rather localhost:8080/MyAppService.

There are a couple of ways I can do it. One is to rename the war or rename the exploded war. I want to know the best practice here. Jenkins will be pulling the artifacts from Nexus and pushing to different environments that runs Tomcat.

Can I configure Jenkins to rename the war before pushing it?

Thanks

Upvotes: 0

Views: 1310

Answers (2)

Gerold Broser
Gerold Broser

Reputation: 14792

See Apache Tomcat 7, The Context Container, Naming:

If you want to deploy a WAR file or a directory using a context path that is not related to the base file name then one of the following options must be used to prevent double-deployment:

  • Disable autoDeploy and deployOnStartup and define all Contexts in server.xml
  • Locate the WAR and/or directory outside of the Host's appBase and use a context.xml file with a docBase attribute to define it.

Upvotes: 0

Shmulik Klein
Shmulik Klein

Reputation: 3914

Our solution was renaming the WAR artifact using a shell script just after the build and prior to the deployment to the environments (we are using Teamcity, but such an option suits Jenkins as well).

I'm not sure about gradle, but I know for sure maven have a <finalName> property which allow you to explicitly provide the final name of the WAR artifact. I'm pretty sure gradle have it to..

(UPDATE: In build.gradle you can set the archive name:

war.archiveName "YOUR_SPECIAL_NAME.war"

Check gradle reference)

Upvotes: 1

Related Questions