Files
wedding-page/cicd/Jenkinsfile
Sciocatti 2559a35503
Some checks failed
Home Cluster Builds/wedding-page/pipeline/head There was a failure building this commit
Updated Jenkinsfile to read branch name.
2023-01-07 18:21:34 +02:00

66 lines
1.8 KiB
Groovy

#!groovy
pipeline {
agent {
kubernetes {
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
name: wedding-fe-env.BRANCH_NAME-build
spec:
serviceAccountName: jenkins-admin
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
command: ["tail"]
args: ["-f", "/dev/null"]
volumeMounts:
- name: kaniko-secret
mountPath: /kaniko/.docker
- name: deploy
image: 192.168.195.195:30000/nginx:latest
command: ["tail"]
args: ["-f", "/dev/null"]
restartPolicy: Never
volumes:
- name: kaniko-secret
secret:
secretName: dockercred
items:
- key: .dockerconfigjson
path: config.json
"""
}
}
stages {
stage('Build') {
steps {
sh 'echo "No build steps configured."'
}
}
stage('Test') {
steps {
sh 'echo "No test steps configured."'
}
}
stage('Docker Build and Push') {
steps {
container("kaniko") {
sh '/kaniko/executor --dockerfile `pwd`/cicd/'+env.BRANCH_NAME+'}/Dockerfile --context `pwd` --destination 192.168.195.195:30000/wedding-fe:'+env.BRANCH_NAME
}
}
}
stage('Kubernetes Deploy') {
steps {
container("deploy") {
sh 'curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.24.3/bin/linux/arm64/kubectl"'
sh 'chmod u+x ./kubectl'
sh 'sed -ie "s/{{replaceMe}}/`date +%s`/g" `pwd`/cicd/'+env.BRANCH_NAME+'/deployment.yaml'
sh './kubectl replace -f `pwd`/cicd/`env.BRANCH_NAME`/deployment.yaml'
}
}
}
}
}