-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
71 lines (66 loc) · 3.2 KB
/
Jenkinsfile
File metadata and controls
71 lines (66 loc) · 3.2 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
pipeline {
agent any
environment{
ACR_CRED = credentials('acr_creds')
}
stages {
stage('ACR Login') {
steps{
sh 'docker login devops2022.azurecr.io -u $ACR_CRED_USR -p $ACR_CRED_PSW'
}
}
stage('Image Building') {
steps {
//sh 'docker build -t devops2022.azurecr.io/pierre_nginx:$GIT_COMMIT .'
//sh 'docker push devops2022.azurecr.io/pierre_nginx:$GIT_COMMIT'
//sh 'docker rmi devops2022.azurecr.io/pierre_nginx:$GIT_COMMIT'
sh 'docker build -t devops2022.azurecr.io/team1/test:$BUILD_NUMBER .'
}
}
stage('Image Pushing'){
steps{
sh 'docker push devops2022.azurecr.io/team1/test:$BUILD_NUMBER'
}
}
stage('Update image in deployment file') {
steps{
checkout([$class: 'GitSCM', branches: [[name: '*/main']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '2eb747c4-f19f-4601-ab83-359462e62482', url: 'https://github.com/Brights-DevOps-2022-Script/argocd-team1.git']]])
withCredentials([usernamePassword(credentialsId: '2eb747c4-f19f-4601-ab83-359462e62482', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh 'sed -i "s|image: .*|image: devops2022.azurecr.io/team1/test:$BUILD_NUMBER|" Kub_pierre/nginx.yaml'
sh 'git add Kub_pierre/nginx.yaml'
sh 'git commit -m "new deployment"'
sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/Brights-DevOps-2022-Script/argocd-team1.git HEAD:main"
}
}
}
//stage('Deploy') {
// agent {
// docker {
// image 'alpine/k8s:1.23.16'
// args '-u root'
//}
//}
//environment{
// KUB_CONF = credentials('k8s_config')
//}
//steps{
// withKubeConfig([credentialsId: 'k8s_config']){
//sh 'kubectl delete namespace pierre-space-second'
//sh 'kubectl create namespace pierre-space-second'
// SED ..................
//sh 'kubectl apply -f nginx.yml'
//sh 'kubectl get namespaces'
//sh 'kubectl set image -n pierre-space-second deployment/nginx-deployment-pierre nginx=devops2022.azurecr.io/pierre_nginx:$GIT_COMMIT'
//sh 'kubectl get all -n pierre-space-second'
//sh 'kubectl get services -n pierre-space-second'
//sh 'apk update && apk add xdg-utils'
//script{
//def output = sh(script: 'kubectl --kubeconfig=$KUB_CONF get service load-balancer -n pierre-space-second', returnStdout: true)
//LOAD_BALANCER_IP=output.split("\n")[1].split()[3].toString()
//echo "IP: http://${LOAD_BALANCER_IP}"
//}
//}
//}
// }
}
}