Jenkins Job - Creating a zip file with war file, appspec.yml and scripts folder - maven

I have created a build with Jenkins for a spring boot application and it is creating a war file.
Now I want to create a second job which should create a zip file with the war file created and appsepc.yml file and a folder "scripts" folder which contains some shell script that the appspec.yml file uses. Can anyone let me know how to do this?
The job name is "Package" so the following is the structure where the different files are.
.jenkins\workspace\Package\target\cpproject.war
.jenkins\workspace\Package\appspec.yml
.jenkins\workspace\Package\scripts\after_install.sh
.jenkins\workspace\Package\scripts\before_install.sh
.jenkins\workspace\Package\scripts\start_server.sh
.jenkins\workspace\Package\scripts\stop_server.sh
Thank you.

See the Maven Assembly Plugin:
The Assembly Plugin for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files.
Currently it can create distributions in the following formats:
zip
...

Related

Copy jar file to multiple location with gradle

I'm working with a Spring Boot App, and I want to copy the jar files as a dependency to libs folder of multiple projects. I have all the below projects in the same dir and the jar file is located in common project, the jar file is located in common/build/libs/*.jar:
reward
product
membership
client
common (jar's file location)
I am able to copy it to a single location at a times with this below snipped script:
task deploy (type: Copy) {
from "build/libs/le-common-1.0.0-SNAPSHOT-plain.jar"
into "${project.rootProject}/../../le-reward/libs"
Any help would be really appreciated, thanks in advance.

Read files within maven plugin

I am trying to create a maven-plugin that generates new files based on a template file (basically using the FreeMarker language). I can successfully generate the files if I run the maven plugin from the directory of my maven-plugin project since my plugin accesses the template file based on a relative path.
However, if I try to run the plugin in some other java project directory, I cannot find the template file. I do not want to copy the templated file into the new java project.
I searched around to see if the maven plugin can access files within itself when another project is using the plugin but wasn't successful. Most of the documentation refers to accessing the java project files, and not the maven-plugin files.
Is this even possible or is there a better approach/workaround to tackle the problem?
Edit (Directory structure):
Maven-Plugin (FileGenerator):
src
--main
--java
--FileGenerator.java (references the TemplateFile based on the path to the root project)
TemplateFile
If I run the plugin as a standalone, I am able to generate new files based on the TemplateFile. I achieve the following structure
Maven-Plugin (FileGenerator):
src
--main
--java
--FileGenerator.java
TemplateFile
NewFile1
NewFile2
However, if I run the plugin in another directory (such as part of another java project) with the command mvn myplugin:mypluginplugin:1.0-SNAPSHOT:build
Another Java Project
src
--main
--java
--AnotherFile.java
pom.xml
I get an error mentioning that the TemplateFile cannot be found. Is there a way for the plugin to reference the TemplateFile regardless of where it is run at?
Ideal Output After running plugin
Another Java Project
src
--main
--java
--AnotherFile.java
pom.xml
NewFile1
NewFile2

How can I generate multiple Jenkins artifacts and zip them together?

I'm using Jenkins to generate a war file, which so far, works, but I need to grab this war file and zip it together with some script files located in the project's workspace.
I'm really new with Jenkins and don't know how to proceed, any help would be appreciated.
Thank you

How to handle shared jar file in maven

I have a project base on Ant build ,I want to change the build tool from Ant to maven,But there is a big problem .
I have a jar file in my project ,and it can be modified by multi developers.
The jar file is located on special system and there is text file beside it.
Every time each developer change the jar file ,he/she set the flag(is Editing?) inside the text file to true while editing the jar file.
When he/she finished editing the jar file,he/she set the flag inside the text file to false,and then copy it to lib folder in project.
How could I handle this process in maven repository ?
I am not very sure about the process. But you can try to use Maven Ant run plugin. I t will help you to mimic ant build.

CMYKJPEGImageReaderSpi not loading

I was having an issue of reading CMYK JPEG images , and have used below url as reference for solving the issue.
http://www.randelshofer.ch/blog/2011/08/reading-cmyk-jpeg-images-with-java-imageio/
I have given the configuration org.monte.media.jpeg.CMYKJPEGImageReaderSpi in the file javax.imageio.spi.ImageReaderSpi under path /META-INF/services/javax.imageio.spi.ImageReaderSpi.
This works perfectly inside eclipse and the image reader is loaded successfully.
This file is not loading when deployed , i can find the folder and the file in the generated war file in my desired jar file inside lib folder, i guess i need to add it to java classpath.
Please help me to add to classpath or if there is any other issue with it.
You need to add this file as a static resource to your build lifecycle.
For Ant or Gradle you just need to write a simple copy task (Ant task, Gradle task), for Maven you can use Maven Resources Plugin.
After that your file should appears in your app package.

Resources