-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
52 lines (47 loc) · 1.81 KB
/
Jenkinsfile
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
pipeline {
agent any
stages {
stage('Initialize Git POLL SCM Feature') {
steps {
//Enable remote triggers
script {
properties([[$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/bipin115/AngularDocker_CI-CD_Workflow.git'], pipelineTriggers([pollSCM('* * * * *')])])
}
}
}
stage('Git project checkout') {
steps {
git branch: 'main', url: 'https://github.com/bipin115/AngularDocker_CI-CD_Workflow.git'
}
}
stage('Clean Existing Images and Stop and remove Running container') {
steps {
catchError (buildResult:'SUCCESS', stageResult: 'FAILURE') {
sh "docker images"
sh "docker container ls"
sh "docker container stop angular_dockerwebapp"
sh "docker rm -f angular_dockerwebapp"
sh "docker image rm -f bipin115/angular_dockerwebapp"
}
}
}
stage('Docker Build and Tag') {
steps {
sh 'docker build -t angular_dockerwebapp:latest .'
sh 'docker tag angular_dockerwebapp bipin115/angular_dockerwebapp:latest'
}
}
stage('Publish image to Docker Hub') {
steps {
withDockerRegistry([ credentialsId: "dockerHub", url: "" ]) {
sh 'docker push bipin115/angular_dockerwebapp:latest'
}
}
}
stage('Run Docker container') {
steps {
sh "docker run --name angular_dockerwebapp -d -p 9090:80 bipin115/angular_dockerwebapp"
}
}
}
}