38 lines
1.2 KiB
Groovy
38 lines
1.2 KiB
Groovy
#!groovy
|
|
|
|
pipeline {
|
|
agent {
|
|
kubernetes {
|
|
defaultContainer 'jnlp'
|
|
yaml """
|
|
apiVersion: v1
|
|
kind: Pod
|
|
metadata:
|
|
name: {{k3sApp}}-"""+env.BRANCH_NAME+"""-build
|
|
spec:
|
|
serviceAccountName: jenkins-admin
|
|
containers:
|
|
- name: deploy
|
|
image: 192.168.195.195:30000/nginx:latest
|
|
command: ["tail"]
|
|
args: ["-f", "/dev/null"]
|
|
restartPolicy: Never
|
|
"""
|
|
}
|
|
}
|
|
stages {
|
|
stage('Kubernetes Deploy') {
|
|
steps {
|
|
container("deploy") {
|
|
withCredentials([string(credentialsId: "{{deploySecret}}", variable: "postgresPassword")]) {
|
|
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 'sed -ie "s/{{postgresPassword}}/${postgresPassword}/g" `pwd`/cicd/'+env.BRANCH_NAME+'/deployment.yaml'
|
|
sh './kubectl apply -f `pwd`/cicd/'+env.BRANCH_NAME+'/deployment.yaml'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |