-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
51 lines (45 loc) · 1.3 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
pipeline {
agent any
environment {
DOCKER_HUB_REPO = 'mbeng44'
IMAGE_NAME = 'worker'
IMAGE_TAG = 'latest'
DOCKER_CREDENTIALS = '8461b105-3d7c-4d95-b34d-da4af62b3a16'
}
stages {
stage('Clone Repository') {
steps {
script {
echo 'Cloning the vote repository...'
git branch: 'main', url: 'https://github.com/mbeng44/worker.git'
}
}
}
stage('Build Docker Image') {
steps {
script {
echo 'Building Docker image...'
docker.build("${DOCKER_HUB_REPO}/${IMAGE_NAME}:${IMAGE_TAG}")
}
}
}
stage('Push Docker Image') {
steps {
script {
echo 'Pushing Docker image to DockerHub...'
docker.withRegistry('https://index.docker.io/v1/', "${DOCKER_CREDENTIALS}") {
docker.image("${DOCKER_HUB_REPO}/${IMAGE_NAME}:${IMAGE_TAG}").push()
}
}
}
}
}
post {
always {
echo 'Pipeline completed.'
}
failure {
echo 'Pipeline failed. Check logs for details.'
}
}
}