forked from javahometech/my-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create jenkins-pipeline-9am-sep-2018
- Loading branch information
javahometech
authored
Sep 7, 2018
1 parent
db609fa
commit 6d093a1
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
try{ | ||
node{ | ||
stage('Git Checkout'){ | ||
git credentialsId: 'github', | ||
url: 'https://github.com/javahometech/my-app', | ||
branch: "${params.gitBranch}" | ||
} | ||
|
||
stage('Maven Build'){ | ||
sh 'mvn clean package' | ||
} | ||
stage('Deploy to Dev'){ | ||
sh 'mv target/*.war target/myweb.war' | ||
sshagent(['tomcat-dev']) { | ||
sh 'ssh [email protected] rm -rf /opt/tomcat8/webapps/myweb*' | ||
sh 'scp target/myweb.war [email protected]:/opt/tomcat8/webapps/' | ||
sh 'ssh [email protected] sudo service tomcat restart' | ||
} | ||
slackSend channel: '#devops-2', | ||
color: 'good', | ||
message: "Job - ${env.JOB_NAME}, Completed successfully Build URL is ${env.BUILD_URL}" | ||
|
||
|
||
} | ||
} | ||
|
||
}catch(error){ | ||
slackSend channel: '#devops-2', | ||
color: 'danger', | ||
message: "Job - ${env.JOB_NAME}, Failed, Build URL is ${env.BUILD_URL}" | ||
error 'Something wrong' | ||
} |