49 lines
1.3 KiB
Groovy
49 lines
1.3 KiB
Groovy
pipeline {
|
|
agent { label "dind" }
|
|
|
|
stages {
|
|
|
|
stage('Create Docker image') {
|
|
steps {
|
|
container('docker') {
|
|
sh """
|
|
docker build -t docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} .
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Publish Docker image') {
|
|
when { branch 'master' }
|
|
environment {
|
|
DOCKER_CREDS = credentials('Harbor')
|
|
}
|
|
steps {
|
|
container('docker') {
|
|
sh """
|
|
docker login docker.cloud.cluster.fun -u $DOCKER_CREDS_USR -p $DOCKER_CREDS_PSW
|
|
docker tag docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} docker.cloud.cluster.fun/averagemarcus/blog:latest
|
|
docker push docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT}
|
|
docker push docker.cloud.cluster.fun/averagemarcus/blog:latest
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Restart deployment') {
|
|
when { branch 'master' }
|
|
steps {
|
|
container('kubectl') {
|
|
sh """
|
|
set +x
|
|
mkdir -p ~/.kube/
|
|
printf "\$CLOUD_KUBECONFIG" > ~/.kube/config
|
|
kubectl --kubeconfig ~/.kube/config rollout restart deployment/blog --namespace default
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|