mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
89 lines
2.1 KiB
Groovy
89 lines
2.1 KiB
Groovy
pipeline{
|
|
|
|
agent any
|
|
|
|
options {
|
|
|
|
disableConcurrentBuilds()
|
|
}
|
|
|
|
environment{
|
|
|
|
|
|
CURRENT_TIME = """${sh(
|
|
returnStdout: true,
|
|
script: 'date "+%Y-%m-%d-%H-%M-%S"'
|
|
)}"""
|
|
|
|
}
|
|
|
|
|
|
|
|
triggers {
|
|
pollSCM 'H/3 * * * * '
|
|
GenericTrigger(
|
|
genericVariables: [
|
|
[key: 'ref', value: '$.ref']
|
|
],
|
|
|
|
causeString: 'Triggered on $ref',
|
|
|
|
token: 'coal',
|
|
tokenCredentialId: '',
|
|
|
|
printContributedVariables: true,
|
|
printPostContent: true,
|
|
|
|
silentResponse: false,
|
|
|
|
shouldNotFlatten: false,
|
|
|
|
regexpFilterText: '$ref',
|
|
regexpFilterExpression: 'refs/heads/' + BRANCH_NAME
|
|
)
|
|
}
|
|
stages{
|
|
|
|
|
|
stage("打包"){
|
|
|
|
|
|
steps{
|
|
|
|
sh 'printenv'
|
|
|
|
withCredentials([usernamePassword(credentialsId: 'aliyun_cr_lihongjie', passwordVariable: 'p', usernameVariable: 'u')]) {
|
|
|
|
sh "docker login -u ${u} -p ${p} registry-vpc.cn-beijing.aliyuncs.com"
|
|
}
|
|
sh "docker build . -t registry-vpc.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest"
|
|
sh "docker tag registry-vpc.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest registry-vpc.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-${env.CURRENT_TIME}"
|
|
sh "docker push registry-vpc.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest"
|
|
sh "docker push registry-vpc.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-${env.CURRENT_TIME}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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}"
|
|
//
|
|
//
|
|
// }
|
|
//
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
} |