-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
50 lines (44 loc) · 1.64 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 {
environment {
buildNumber = "${currentBuild.number}"
KUBECONFIG = '/var/lib/jenkins/.kube/config'
}
agent any
stages {
stage('Fetch Code From GitHub') {
steps {
git "https://github.com/tteog-ip/dash-back.git"
}
}
stage('AWS Credentials') {
steps {
withAWS(credentials: 'AWS-KEY', region: 'ap-northeast-2') {
sh 'aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 728156710202.dkr.ecr.ap-northeast-2.amazonaws.com/dash-back'
}
}
}
stage('Build Docker Image') {
steps {
sh 'docker system prune -f && docker build --force-rm --no-cache --tag 728156710202.dkr.ecr.ap-northeast-2.amazonaws.com/dash-back:v$buildNumber .'
}
}
stage('ECR Push') {
steps {
sh 'docker push 728156710202.dkr.ecr.ap-northeast-2.amazonaws.com/dash-back:v$buildNumber'
}
}
stage('Change Tag in GitHub') {
steps {
git credentialsId: 'jenkins-github2',
url: 'https://github.com/tteog-ip/dash-argocd',
branch: 'main'
sh "sed -i 's#728156710202.dkr.ecr.ap-northeast-2.amazonaws.com/dash-back:v.*#728156710202.dkr.ecr.ap-northeast-2.amazonaws.com/dash-back:v$buildNumber#g' back/deployment.yaml"
sh "git add back/deployment.yaml"
sh "git commit -m 'Update Image Tag $buildNumber'"
withCredentials([gitUsernamePassword(credentialsId: 'github-token-cykim', gitToolName: 'Default')]) {
sh 'git push origin main'
}
}
}
}
}