mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 14:55:51 +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",
|
git url: "git@github.com:azure-devops/spring-petclinic.git",
|
||||||
credentialsId: "github_ssh_key",
|
credentialsId: "github_ssh_key",
|
||||||
branch: "ignite"
|
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') {
|
stage('image build') {
|
||||||
environment {
|
|
||||||
sha = sh(script: 'git rev-parse --short HEAD', returnStdout: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
acrQuickTask azureCredentialsId: "jenkins-sp",
|
acrQuickTask azureCredentialsId: "jenkins-sp",
|
||||||
registryName: "jenkinsdemosacr",
|
registryName: "jenkinsdemosacr",
|
||||||
resourceGroupName: "demo-aks",
|
resourceGroupName: "demo-aks",
|
||||||
local: "",
|
local: "",
|
||||||
dockerfile: "Dockerfile",
|
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') {
|
stage('update staging config') {
|
||||||
environment {
|
when {
|
||||||
sha = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
environment name: "DEPLOY_TO", value: 'staging'
|
||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
dir('infra/kube/workloads/staging') {
|
dir('infra/kube/workloads/staging') {
|
||||||
sh '''
|
sh '''
|
||||||
sed -i -e "s/master-......./master-\${sha}/" deployment.yaml
|
sed -i -e "s/pet-......./pet-\${IMAGE_TAG}/" deployment.yaml
|
||||||
sed -i -e "s/master-......./master-\${sha}/" service.yaml
|
sed -i -e "s/pet-......./pet-\${IMAGE_TAG}/" service.yaml
|
||||||
git add *
|
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
|
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
|
name: pet-clinic
|
||||||
namespace: production
|
namespace: production
|
||||||
labels:
|
labels:
|
||||||
version: master-507549c
|
version: v0.0.0
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app: auth-service
|
app: auth-service
|
||||||
version: master-507549c
|
version: v0.0.0
|
||||||
ports:
|
ports:
|
||||||
- port: 80
|
- port: 80
|
||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
|
|
|
@ -12,12 +12,12 @@ spec:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: pet-clinic
|
app: pet-clinic
|
||||||
version: master-507549c
|
version: pet-829376a
|
||||||
|
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: pet-clinic
|
- name: pet-clinic
|
||||||
image: "jenkinsdemosacr.azurecr.io/pet-clinic:master-507549c"
|
image: "jenkinsdemosacr.azurecr.io/pet-clinic:pet-829376a"
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
|
|
|
@ -4,11 +4,11 @@ metadata:
|
||||||
name: pet-clinic
|
name: pet-clinic
|
||||||
namespace: staging
|
namespace: staging
|
||||||
labels:
|
labels:
|
||||||
version: master-507549c
|
version: pet-829376a
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app: auth-service
|
app: auth-service
|
||||||
version: master-507549c
|
version: pet-829376a
|
||||||
ports:
|
ports:
|
||||||
- port: 80
|
- port: 80
|
||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
|
|
Loading…
Reference in a new issue