irt-service/Jenkinsfile
2023-10-04 14:27:18 +00:00

48 lines
1.9 KiB
Groovy

pipeline {
agent {
kubernetes {
label "kaniko-${UUID.randomUUID().toString()}"
inheritFrom 'kaniko'
}
}
environment {
REPOSITORY = 'yardstick/measure-solver'
}
stages {
stage('Build Kaniko image') {
steps {
withVault([ vaultSecrets: [
[
path: "ci/general",
engineVersion: 1,
secretValues: [
[envVar: 'NEXUS_TOKEN', vaultKey: 'SONATYPE_DEPLOYMENT_USER_TOKEN']
]
]
]]) {
withCredentials([usernamePassword(credentialsId: 'DockerHubAccessYardstick', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
container('kaniko') {
checkout scm
// Setup docker credentials
sh 'echo "{\\"auths\\":{\\"https://index.docker.io/v1/\\":{\\"auth\\":\\"$(printf "%s:%s" "$USER" "$PASS" | base64 | tr -d \'\n\')\\"}}}" > /kaniko/.docker/config.json'
// Execute kaniko build
sh """
/kaniko/executor -f `pwd`/Dockerfile \
-c `pwd` \
--insecure=true \
--insecure-registry=docker-registry.default:5000 \
--cache=true \
--build-arg NEXUS_TOKEN=${NEXUS_TOKEN} \
--cache-repo=docker-registry.default:5000/${REPOSITORY} \
--destination ${env.REPOSITORY}:\$(echo ${BRANCH_NAME} | grep -Eo 'feature/([A-Za-z]+-[0-9]*)' | grep -Eo '[A-Za-z]+-[0-9]*' || \
echo ${BRANCH_NAME} | grep -Eo '(release|hotfix)/[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+' | grep -Eo '[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+' || \
echo ${BRANCH_NAME} | grep -Eo 'YASDEV-([[:digit:]]*)')
"""
}
}
}
}
}
}
}