forked from ramchandra-guthula/sample-java-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
59 lines (52 loc) · 2.08 KB
/
Jenkinsfile
File metadata and controls
59 lines (52 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
pipeline {
agent any
stages {
stage ('Clone') {
steps {
//git credentialsId: 'ram github credentials', url: 'https://github.com/ramchandra-guthula/sample-java-app.git'
git branch: 'master', url: 'https://github.com/ramchandra-guthula/sample-java-app.git'
}
}
stage ('Init') {
steps {
sh '''
ls -lrt $WORKSPACE
'''
}
}
stage ('Build Project') {
tools {
maven 'maven-3.8'
}
steps {
sh " mvn clean install"
}
}
stage('Get Ansible Scripts') {
steps {
// We are getting anisble scripts to create an Instance and deploy the war file to tomcat
// We can even add the files in the same repo by creatuing seperate folder instead of cloneing from a separate repo
git branch: 'main', url: 'https://github.com/ramchandra-guthula/ansible_practice.git'
}
}
stage('Deploy WAR file') {
steps {
script {
dir("$WORKSPACE/ec2_tomcat/") { // This to excute below steps from the $WORKSPACE/ec2_tomcat directory
ansiColor('xterm'){ // We need to install ansiColour plugin to use this ansiColour
ansiblePlaybook credentialsId: 'jenkins_slave_ssh_keys', installation: 'ansible-2.9', colorized: true, playbook: '$WORKSPACE/ec2_tomcat/site.yaml'
// We need to install Ansible plugin and configure Ansible with out any executable, we must install ansible in local
currentBuild.displayName = "# {BUILD_NUMBER}-java-app"
currentBuild.description = "This is sample app"
}
}
}
}
}
stage ('Clean workspace'){
steps {
cleanWs()
}
}
}
}