mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 06:45:49 +00:00
Update staging file with 829376a
commit
This commit is contained in:
parent
829376afd9
commit
c55dfe3d2c
5 changed files with 65 additions and 17 deletions
46
Jenkinsfile
vendored
46
Jenkinsfile
vendored
|
@ -7,6 +7,18 @@ pipeline {
|
|||
git url: "git@github.com:azure-devops/spring-petclinic.git",
|
||||
credentialsId: "github_ssh_key",
|
||||
branch: "ignite"
|
||||
|
||||
script {
|
||||
env.SHA = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||||
env.GIT_TAG = sh(script: 'git tag -l --points-at HEAD', returnStdout: true).trim()
|
||||
if (env.GIT_TAG == '') {
|
||||
env.IMAGE_TAG = SHA
|
||||
env.DEPLOY_TO = "staging"
|
||||
} else {
|
||||
env.IMAGE_TAG = env.GIT_TAG
|
||||
env.DEPLOY_TO = "production"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,32 +33,44 @@ pipeline {
|
|||
|
||||
|
||||
stage('image build') {
|
||||
environment {
|
||||
sha = sh(script: 'git rev-parse --short HEAD', returnStdout: true)
|
||||
}
|
||||
|
||||
steps {
|
||||
acrQuickTask azureCredentialsId: "jenkins-sp",
|
||||
registryName: "jenkinsdemosacr",
|
||||
resourceGroupName: "demo-aks",
|
||||
local: "",
|
||||
dockerfile: "Dockerfile",
|
||||
imageNames: [[image: "jenkinsdemosacr.azurecr.io/pet-clinic:master-${sha}"]]
|
||||
imageNames: [[image: "jenkinsdemosacr.azurecr.io/pet-clinic:pet-${IMAGE_TAG}"]]
|
||||
}
|
||||
}
|
||||
|
||||
stage('update staging config') {
|
||||
environment {
|
||||
sha = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||||
when {
|
||||
environment name: "DEPLOY_TO", value: 'staging'
|
||||
}
|
||||
|
||||
steps {
|
||||
dir('infra/kube/workloads/staging') {
|
||||
sh '''
|
||||
sed -i -e "s/master-......./master-\${sha}/" deployment.yaml
|
||||
sed -i -e "s/master-......./master-\${sha}/" service.yaml
|
||||
sed -i -e "s/pet-......./pet-\${IMAGE_TAG}/" deployment.yaml
|
||||
sed -i -e "s/pet-......./pet-\${IMAGE_TAG}/" service.yaml
|
||||
git add *
|
||||
git commit -m "Update staging file with \${sha} commit"
|
||||
git commit -m "Update staging file with \${IMAGE_TAG} commit"
|
||||
git push origin ignite
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('update production config') {
|
||||
when {
|
||||
environment name: "DEPLOY_TO", value: 'production'
|
||||
}
|
||||
steps {
|
||||
dir('infra/kube/workloads/production') {
|
||||
sh '''
|
||||
sed -i -e "s/v[0-9]\\.[0-9]\\.[0-9]/\${IMAGE_TAG}/" deployment.yaml
|
||||
sed -i -e "s/v[0-9]\\.[0-9]\\.[0-9]/\${IMAGE_TAG}/" service.yaml
|
||||
git add *
|
||||
git commit -m "Update production file with \${IMAGE_TAG} commit"
|
||||
git push origin ignite
|
||||
'''
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: pet-clinic
|
||||
namespace: staging
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: pet-clinic
|
||||
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: pet-clinic
|
||||
version: v0.0.0
|
||||
|
||||
spec:
|
||||
containers:
|
||||
- name: pet-clinic
|
||||
image: "jenkinsdemosacr.azurecr.io/pet-clinic:v0.0.0"
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
imagePullSecrets:
|
||||
- name: "acr-secret"
|
|
@ -4,11 +4,11 @@ metadata:
|
|||
name: pet-clinic
|
||||
namespace: production
|
||||
labels:
|
||||
version: master-507549c
|
||||
version: v0.0.0
|
||||
spec:
|
||||
selector:
|
||||
app: auth-service
|
||||
version: master-507549c
|
||||
version: v0.0.0
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8080
|
||||
|
|
|
@ -12,12 +12,12 @@ spec:
|
|||
metadata:
|
||||
labels:
|
||||
app: pet-clinic
|
||||
version: master-507549c
|
||||
version: pet-829376a
|
||||
|
||||
spec:
|
||||
containers:
|
||||
- name: pet-clinic
|
||||
image: "jenkinsdemosacr.azurecr.io/pet-clinic:master-507549c"
|
||||
image: "jenkinsdemosacr.azurecr.io/pet-clinic:pet-829376a"
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
imagePullSecrets:
|
||||
|
|
|
@ -4,11 +4,11 @@ metadata:
|
|||
name: pet-clinic
|
||||
namespace: staging
|
||||
labels:
|
||||
version: master-507549c
|
||||
version: pet-829376a
|
||||
spec:
|
||||
selector:
|
||||
app: auth-service
|
||||
version: master-507549c
|
||||
version: pet-829376a
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8080
|
||||
|
|
Loading…
Reference in a new issue