How to generate war file using jenkins Build->Exec

2019-06-13 21:04发布

问题:

  • I am new to Jenkin and svn. I have commited the java project into repository. now how to generate the war file through shell option.

  • What is Post-build Actions->Archive the Artifacts option, what input should i provide in "files to archive option"

回答1:

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.



回答2:

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.



标签: svn jenkins war