Files
coal/Jenkinsfile
2023-08-12 11:38:30 +08:00

54 lines
987 B
Groovy

pipeline{
agent any
options {
disableConcurrentBuilds()
}
triggers {
pollSCM 'H/3 * * * * '
}
stages{
stage("打包"){
steps{
withCredentials([usernamePassword(credentialsId: 'harbor-ci', passwordVariable: 'p', usernameVariable: 'u')]) {
sh "docker login -u ${u} -p ${p} 192.168.0.118"
}
sh "docker build . -t coal:${env.BRANCH_NAME}"
sh "docker tag coal:${env.BRANCH_NAME} 192.168.0.118/coal/coal:${env.BRANCH_NAME}"
sh "docker push 192.168.0.118/coal/coal:${env.BRANCH_NAME}"
}
}
stage("重新部署"){
steps{
sh "kubectl --kubeconfig=homelab.yaml apply -k k8s/${env.BRANCH_NAME}/"
sh "kubectl --kubeconfig=homelab.yaml rollout restart deployment/coal-api --namespace coal-${env.BRANCH_NAME}"
}
}
}
}