Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use WAR file from maven build for CodeDeploy? Edited

Hello,

I am trying to use bitbucket pipeline for building and deploying the artifact onto AWS EC2 using codedeploy. However, I am at a slight disadvantage as I cannot find the output of the 1st step (Maven build) to push to S3. As far as I know, the maven build step (which is my step 1 in bitbucket-pipeline.yml) produces a WAR file. I should zip it with scripts, appspec file and push it on to S3 from where my code deploy app will pick it up. Can anyone help me on where will the bitbucket store the output WAR file after maven build?

 

Thanks,

Ajit

1 answer

0 votes
Graham Gatus Atlassian Team Sep 03, 2018

@ajit54, for a "standard" maven project, you should be able to find your .war file under the "target" directory. Generally it should be target/<artifact>-<version>.war.

You should be able to verify this by running your build commands locally.

If you want to avoid writing additional scripts to build the .zip required by AWS CodeDeploy, you can also try using the maven-assembly-plugin to build the zip.

e.g The following entry in the <build> section of your pom.xml will enable the plugin:

<plugins>
// other plugins here
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>make-zip</id>
<phase>package</phase>
<goals>
<goal>
single
</goal>
</goals>
</execution>
</executions>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/zip.xml</descriptor>
</descriptors>
<finalName>myapp</finalName>
</configuration>
</plugin>
</plugins>

Under src/assembly/zip.xml, you would specify a zip.xml file which contains resources to zip up: 

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>demo-0.0.1-SNAPSHOT.war</include>
</includes>
<outputDirectory>.</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}</directory>
<includes>
<include>appspec.yml</include>
<include>scripts/*</include>
</includes>
<outputDirectory>.</outputDirectory>
</fileSet>
</fileSets>
</assembly>

In the above example, I include my application war, as well as an appspec file, and a few scripts which are referenced from within the appspec. 

This would suite a project with a similar structure to:

.
├── appspec.yml
├── pom.xml
├── scripts
│   ├── start.sh
│   └── stop.sh
├── src
│   ├── assembly
│   │   └── zip.xml
│   └── main
│   └── java
│      └── <your app files>
│  
└── target
  └── demo-0.0.1-SNAPSHOT.war

This will produce a "myapp.zip" file which can be uploaded to S3 and deployed using code deploy.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

241 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you