调整dockerfile

This commit is contained in:
2024-07-29 16:51:07 +08:00
parent 2c2dac0f11
commit b8e4e2c52b

44
Jenkinsfile vendored
View File

@@ -8,6 +8,15 @@ pipeline{
}
parameters {
string(
name: 'BUILD_TIME',
defaultValue: new Date().format("yyyy-MM-dd-HH-mm-ss", TimeZone.getTimeZone("Asia/Shanghai")),
description: 'Build time in UTC'
)
}
triggers {
pollSCM 'H/3 * * * * '
}
@@ -18,13 +27,14 @@ pipeline{
steps{
withCredentials([usernamePassword(credentialsId: 'harbor-ci', passwordVariable: 'p', usernameVariable: 'u')]) {
withCredentials([usernamePassword(credentialsId: 'codeup_lihongjie0209', passwordVariable: 'p', usernameVariable: 'u')]) {
sh "docker login -u ${u} -p ${p} 192.168.0.118"
sh "docker login -u ${u} -p ${p} registry.cn-beijing.aliyuncs.com"
}
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}"
sh "docker build . -t registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest"
sh "docker tag registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-${params.BUILD_TIME}"
sh "docker push registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest"
sh "docker push registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-${params.BUILD_TIME}"
}
@@ -34,18 +44,18 @@ pipeline{
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}"
}
}
// 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}"
//
//
// }
//
// }
}