-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
64 lines (61 loc) · 1.87 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
53
54
55
56
57
58
59
60
61
62
63
64
pipeline {
agent any
environment {
DOCKER_IMAGE_NAME = 'docker.io/engsabry/nginx-argo'
DOCKER_IMAGE_TAG = 'latest'
DOCKER_CREDENTIALS_ID = 'dockerhub-token'
GITHUB_CREDENTIALS_ID = 'github-pat'
}
stages {
stage('Code Checkout') {
steps {
echo 'Checking out code...'
checkout([
$class: 'GitSCM',
branches: [[name: '*/main']],
userRemoteConfigs: [[
url: 'https://github.com/OpsMo/argocd-app.git',
credentialsId: GITHUB_CREDENTIALS_ID
]]
])
}
}
// added this for debug
stage('Debug Workspace') {
steps {
sh 'pwd'
sh 'ls -R'
}
}
stage('Build Docker Image') {
steps {
script {
// echo "Building Docker image: $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG"
// docker.build("$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG")
sh 'docker build -t docker.io/engsabry/nginx-argo:latest -f app-ci-image/Dockerfile app-ci-image'
}
}
}
stage('Push Docker Image') {
steps {
script {
echo "Pushing Docker image: $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG"
docker.withRegistry('https://index.docker.io/v1/', DOCKER_CREDENTIALS_ID) {
docker.image("$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG").push()
}
}
}
}
}
post {
always {
echo 'Pipeline completed.'
}
success {
echo 'Pipeline succeeded!'
}
failure {
echo 'Pipeline failed!'
}
}
}