How to create a .war archive for jenkins artifacts - jenkins

I'm running a code review project in jenkins and trying to archive the artifacts that are generated into a .war file.
Instead it is generating the artifacts as .zip file in jenkins
I tried searching a lot. But nothing is very helpful.
Is there any workaround to generate artifacts as .war file instead of .zip.
Am I doing this correctly? Or please can anyone explain the step-4 if that is what I'm doing.

Archives, when configured relative to $WORKSPACE are generated in a .zip file only. If your generated o/p is a .war file and you are archiving the same, then it will be a .war file inside .zip file.
Can you put more details about what are the generated artifacts are and why they are needed as .war only? As well as what are you going to do with .war? Deploying anywhere?

It pretty straight forward. Look at the screenshots to configure the same.

Related

Is there any way to get Jenkins artifacts in Gitlab pipeline?

Basically the opposite of this question: Is there any way to get Gitlab pipeline artifacts in Jenkins?
My project is built on Jenkins. It generates a JavaDoc.
I want to publish this JavaDoc as a Gitlab Pages.
So I would need my gitlab-yml to be able to retrieve the produced javadoc from Jenkins.
Alternatively, my artifacts are stored on a network drive, so an access to this network drive would work too
I think that this plugin could be helpful to you...
There is a plugin called Archived Artifact Url Viewer. It seems to be like you needs.
"Jenkins plugin to view contents of a file inside a zip or jar file under a subdirectory of artifacts directory of a build The url to access a file inside a zip or jar archive within the artifact folder of a build is as follows"
/archivedArtifacts/artifact/<job_name>/<build_number/<relative location of zip or jarfile within artifact folder>/<location of file within archive>
Ex:
http://<jenkins_url>/archivedArtifacts/artifact/Build%20-%20Dev/10526/junit-logs.zip/junit.log
https://plugins.jenkins.io/archived-artifact-url-viewer/

Jenkins Nexus Upload Plugin Failing

enter image description hereAm using Nexus Artifact Uploader plugin to upload my .ear file to Nexus. Its working fine for all jobs except one. In this particular job am supposed to download an existing .ear file from nexus, do some editing to config files within the ear, repackage it as UpgradeTrue.ear and UpgradeFalse.ear and upload both the ears to the same location from where I have downloaded the original .ear.
Strangely it tries to upload the file which doesnt exist. Please advise.
Thanks in advance.
Jenkins Log Snippet:

Download full workspace from Jenkins build

I am new to jenkins and I have tried downloading a zip archive of this workspace in jenkins, but I only get a part of it. Source folders like tensorflow or tools are not present inside the archive. Is this normal ?
If so, how do I get all of them inside a zip file ?
Use Archive Artifact plugin, to add your workspace into archive folder which will make it easily down-loadable.
But be aware that, an artifact in the Jenkins sense is the result of a build - the intended output of the build process.
A common convention is to put the result of a build into a build, target or bin directory.
The Jenkins archiver can use globs (target/*.jar) to easily pick up the right file even if you have a unique name per build.
putting a complete workspace into it will take lot of time.

rebuilding grails war file from ant

Grails war file are very big since they contains all the jars and plugins, this can be problematic when deploying on a virtual server since every small change I have to resend the whole war.
I found out that you can build the war file through ant directly on the server and send only the class files which are much smaller in size.
Can anyone tell me practically how this can be done?
Can I modify an existing war by changing some only some class files ?
Thanks,
Dany
You should be able to hook into eventWarStart and customize the war.
See http://www.anyware.co.uk/2005/2009/01/21/excluding-files-from-a-war-with-grails-the-right-way/

Create war without manifest

I need to create a war file through ant build without a manifest file. I want the war to me created without the manifest file.
I am using tag in build.xml to create the war.
you can use <zip/> task with .war extension for destfile attribute to achieve the same result as the <war/> task (without manifest.mf).
<zip destfile="..\...\WarFile.war"basedir="..\basedir" update="true"/>
in case WarFile.war already exists, although you've written I need to create a war file , the attribute update="true" will be of use (by only updating and not overwriting the file).
All a war file is is a zip file in a specific format. That is libraries go in a particular place, class files go elsewhere, etc. The <war> task has sub-entities like <classes/> and <lib> that make configuring a war file correctly without knowing exactly where everything has to go.
However, you can correctly format the war yourself, and use <zip/>.
Why don't you want a manifest file? A manifest, if you don't specify anything, will contain nothing but the Java version used for the build, and the Ant version and won't affect the execution of your war at all.
What you can do is put useful information into the manifest. For example, we use Jenkins for our builds, and we put in the Jenkins project name and the build number which helps us understand what was included in the war.
There's no reason not to use a manifest file. And, a manifest file can contain useful information (which is accessible to the Java program too).

Resources