Continuous deployment with Jenkins

Posted: September 9, 2018 in Jenkins

In this example we’ll copy war file from Jenkins project to Tomcat using Jenkins.

Install Tomcat

configure tomcat credentials:edit file conf\tomcat-users.xml

<role rolename=”manager-script”/>
<role rolename=”admin-gui”/>
<user username=”tomcat” password=”tomcat” roles=”manager-script,admin-gui”/>
</tomcat-users>

If tomcat port needs to be changed, edit file conf\server.xml

<Connector port=”8081″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″ />

Install copy artifact and deploy to container plugins:

Manage Jenkins-Manage Plugins

 

7.png

 

 

8.PNG

 

9.PNG

Create Jenkins job for compiling war file and to invoke other job for copying war files to tommcat (job name:packer)

 

1.PNG

In build step add Invoke top-level Maven targets

select Maven Version and Goals:clean package

2.PNG

In Post-build Action add Archive the artifacts

Files to archive **/*.war (archive all war file)

Add Post-build Action to run other job after this one is executed (deploy_staging)

3.PNG

 

Creating job for copying war file to tomcat (deploy_staging)

Build action:pecify project name (one we created in previous step)

Artifacts to copy:**/*.war

4.PNG

Post-build Actions:

Deploy war/ear to a container:**/*.war

Specify tomcat credentials-click Add to add credentials and Tomcat URL

 

5.png

 

6.PNG

 

Now run first job (packer), it should compile war file and copy it to Tomcat dierctory

 

10.PNG

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s