sandip divekar
sandip divekar

Reputation: 1826

How to generate war file using jenkins Build->Execute shell option?

Upvotes: 0

Views: 11366

Answers (2)

David W.
David W.

Reputation: 107040

How does your war now build from the command line? For example, if you use Ant, you might do:

$ ant war

If you use Maven, it'll be:

$ mvn war

That's the first thing you must know. Jenkins can automatically run an Ant build.xml file or run a pom.xml in Maven. These happen to be two built-in build tasks. However, if you use a shell script or some other command to do the build, you can specify that too in Jenkins. Under the Build section is a Add build step. Select whether to build with Invoke Ant, Build Maven Top Level Targets, Execute Windows Batch Command, Execute Shell, etc. Then fill in the prompts. For example, if you build with Ant, you'll be asked to select the Ant version you want to use, and the target to execute.

Once you actually build something in Jenkins, you need to ask yourself where does the war or whatever you're building actually exist in the working directory. Once you figure that out, you can simply put the location in the Archive Artifacts option. You can also simply put **/*.war, and all war files in your build will be archived. Since it's doubtful that you have more than one war in your project, you may be able to get away with that.

Upvotes: 1

jasonoriordan
jasonoriordan

Reputation: 893

If you have 'committed the java project into repository' then maybe you are generating the war already? After running job check to see if a war is in the target dir in the workspace. If so, it should be a case of setting the archive option to something like, 'target/*.war'.

The question mark next to 'Files to archive' in Post-build Actions->Archive the Artifacts option gives good help,

You can use wildcards like 'module/dist/*/.zip'. See the includes attribute of Ant fileset for the exact format. The base directory is the workspace. You can only archive files that are located in your workspace.

Upvotes: 0

Related Questions