chore: updated Jenkinsfile
Gitea/docker-base-images/jdk14-alpine/pipeline/head There was a failure building this commit Details

fix/fix-agent-installation
amorozov 2023-03-30 19:16:56 +03:00
parent 5e9c7e0cb7
commit 7a5662ff90
1 changed files with 7 additions and 10 deletions

17
Jenkinsfile vendored
View File

@ -1,14 +1,11 @@
def resolveImageTag(env) { def resolveImageTag(env) {
return env.TAG_NAME?.replace(RELEASE_TAG_PREFIX, '') ?: 'latest' return env.TAG_NAME?.replace(env.RELEASE_TAG_PREFIX, '') ?: 'latest'
} }
def resolveImageName(env) { def resolveImageName(env) {
return "${REGISTRY_HOST}/docker-base-images/${IMAGE_BASE_NAME}:${resolveImageTag(env)}" return "${env.REGISTRY_HOST}/docker-base-images/${env.IMAGE_BASE_NAME}:${resolveImageTag(env)}"
} }
def IMAGE_BASE_NAME
def RELEASE_TAG_PREFIX
def REGISTRY_HOST
pipeline { pipeline {
agent { agent {
docker { docker {
@ -22,9 +19,9 @@ pipeline {
steps { steps {
sh "apk update && apk add --no-cache git" sh "apk update && apk add --no-cache git"
script { script {
IMAGE_BASE_NAME = "jdk14-alpine" env.IMAGE_BASE_NAME = "jdk14-alpine"
RELEASE_TAG_PREFIX = "release-" env.RELEASE_TAG_PREFIX = "release-"
REGISTRY_HOST = "git.tswf.io" env.REGISTRY_HOST = "git.tswf.io"
if (env.TAG_NAME == null) { if (env.TAG_NAME == null) {
env.TAG_NAME = sh(returnStdout: true, script: "git tag --points-at HEAD").trim() env.TAG_NAME = sh(returnStdout: true, script: "git tag --points-at HEAD").trim()
} }
@ -38,10 +35,10 @@ pipeline {
} }
stage('push_docker') { stage('push_docker') {
when { when {
tag "${RELEASE_TAG_PREFIX}*" tag "${env.RELEASE_TAG_PREFIX}*"
} }
steps { steps {
sh "docker login ${REGISTRY_HOST} -u ${env.GITEA_USER} -p ${env.GITEA_OAUTH_TOKEN}" sh "docker login ${env.REGISTRY_HOST} -u ${env.GITEA_USER} -p ${env.GITEA_OAUTH_TOKEN}"
sh "docker image push ${resolveImageName(env)}" sh "docker image push ${resolveImageName(env)}"
} }
} }