forked from cbabu85/InsureMe-20Mar
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathJenkinsfile2
55 lines (47 loc) · 1.56 KB
/
Jenkinsfile2
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
pipeline {
agent any
tools {
maven 'M2_HOME'
}
stages {
stage('CheckOut') {
steps {
echo 'Checkout the source code from GitHub'
git branch: 'main', url: 'https://github.com/devopscbabu/InsureProject-Dec3Batch.git'
}
}
stage('Package the Application') {
steps {
echo " Packaing the Application"
sh 'mvn clean package'
}
}
stage('Publish Reports using HTML') {
steps {
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '/var/lib/jenkins/workspace/Insure-Project/target/surefire-reports', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: '', useWrapperFileDirectly: true])
}
}
stage('Docker Image Creation') {
steps {
sh 'docker build -t cbabu85/insureprojectdec3:latest .'
}
}
stage('DockerLogin') {
steps {
withCredentials([usernamePassword(credentialsId: 'Docker-Hub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPassword}"
}
}
}
stage('Push Image to DockerHub') {
steps {
sh 'docker push cbabu85/insureprojectdec3:latest'
}
}
stage('Deploy Application using Ansible') {
steps {
ansiblePlaybook credentialsId: 'private-key', disableHostKeyChecking: true, installation: 'ansible', inventory: '/etc/ansible/hosts', playbook: 'deploy.yml'
}
}
}
}