forked from BThangaraju/calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkinsfile
48 lines (41 loc) · 1.25 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
pipeline {
agent any
environment {
DOCKER_IMAGE_NAME = 'calculator'
GITHUB_REPO_URL = 'https://github.com/samayochita/calculator.git'
}
stages {
stage('Checkout') {
steps {
script {
// Checkout the code from the GitHub repository
git branch: 'main', url: "${GITHUB_REPO_URL}"
}
}
}
stage('Build Docker Image') {
steps {
script {
// Build Docker image
docker.build("${DOCKER_IMAGE_NAME}", '.')
//sh 'docker build -t calculator .'
}
}
}
stage('Push Docker Images') {
steps {
script{
docker.withRegistry('', 'DockerHubCred') {
sh 'docker tag calculator samayochita/calculator'
sh 'docker push samayochita/calculator'
}
}
}
}
stage ('Run Ansible Playbook') {
steps {
sh 'ansible-playbook -i inventory deploy.yml'
}
}
}
}