initial build (#28)

This commit is contained in:
Jarred Hunter 2022-03-17 13:36:53 -05:00 committed by GitHub
parent 13f0f383e0
commit c4a9b41234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

51
Jenkinsfile vendored
View File

@ -1,25 +1,36 @@
def label = "docker-${UUID.randomUUID().toString()}"
podTemplate(label: label, inheritFrom: 'base') {
node(label) {
stage('Checkout Repository') {
container('base') {
checkout scm
}
pipeline {
agent {
kubernetes {
label "kaniko-${UUID.randomUUID().toString()}"
inheritFrom 'kaniko'
}
stage('Login to Dockerhub') {
withCredentials([usernamePassword(credentialsId: 'DockerHubAccessYardstick', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
container('base') {
sh "docker login --username ${USER} --password ${PASS}"
}
environment {
REPOSITORY = 'yardstick/measure-solver'
}
stages {
stage('Build Kaniko image') {
steps {
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 \
--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:]]*)')
"""
}
}
}
}
stage('Build Docker image') {
container('base') {
sh "make display full branch=${BRANCH_NAME}"
}
}
}
}
}