forked from devops-jan23/hello-2048
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
33 lines (32 loc) · 1.17 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
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'docker-compose build'
sh "git tag 1.0.${BUILD_NUMBER}"
sh "docker tag ghcr.io/edugoma/hello-2048:latest ghcr.io/edugoma/hello-2048:1.0.${BUILD_NUMBER}"
sshagent(['Git-hubSSH']) {
sh "git push --tags"
}
}
}
stage('Package'){
steps{
withCredentials([string(credentialsId: 'github-token', variable: 'CR_PAT')]) {
sh "echo $CR_PAT | docker login ghcr.io -u edugoma --password-stdin"
sh 'docker-compose push'
sh "docker push ghcr.io/edugoma/hello-2048:1.0.${BUILD_NUMBER}"
}
}
}
stage('Deploy') {
steps {
sshagent(['ssh-amazon']) {
sh 'ssh -o "StrictHostKeyChecking no" [email protected] docker pull ghcr.io/edugoma/hello-2048:1.0.${BUILD_NUMBER}'
sh """ssh [email protected] docker-compose up -d"""
}
}
}
}
}