-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
40 lines (38 loc) · 1.37 KB
/
Jenkinsfile
File metadata and controls
40 lines (38 loc) · 1.37 KB
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
pipeline {
agent any
stages {
stage('Checkout')
{
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/Phase3']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/Team4-DevWave/Devops', credentialsId: 'hooks']]
])
}
}
stage('Build and Push') {
steps {
// Build the Docker image
dir('nginx') {
sh 'docker build -t hassanhatem/nginx:latest .'
}
// Push the Docker image to a registry
withCredentials([usernamePassword(credentialsId: 'docker', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
sh 'docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD'
sh 'docker push hassanhatem/nginx:latest'
}
}
}
stage('Deploy') {
steps {
// Deploy the Docker image using Docker Compose
sh 'docker-compose -f docker-compose.yml down'
sh 'docker-compose -f docker-compose.yml up -d'
}
}
}
}