mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
bugfix
This commit is contained in:
30
Jenkinsfile
vendored
30
Jenkinsfile
vendored
@@ -8,13 +8,6 @@ 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 {
|
||||
@@ -22,6 +15,25 @@ pipeline{
|
||||
}
|
||||
stages{
|
||||
|
||||
stage('定义变量') {
|
||||
steps {
|
||||
script {
|
||||
// 获取当前时间
|
||||
|
||||
def now = new Date()
|
||||
|
||||
// 格式化时间,例如为 yyyy-MM-dd HH:mm:ss
|
||||
def timeFormatter = new java.text.SimpleDateFormat("yyyy-MM-dd-HH-mm-ss")
|
||||
def currentTime = timeFormatter.format(now)
|
||||
|
||||
// 将格式化的当前时间存储为环境变量
|
||||
environment {
|
||||
CURRENT_TIME = currentTime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage("打包"){
|
||||
|
||||
@@ -32,9 +44,9 @@ pipeline{
|
||||
sh "docker login -u ${u} -p ${p} registry.cn-beijing.aliyuncs.com"
|
||||
}
|
||||
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 tag registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-latest registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-${params.CURRENT_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}"
|
||||
sh "docker push registry.cn-beijing.aliyuncs.com/lihongjie/coal:${env.BRANCH_NAME}-${params.CURRENT_TIME}"
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user