Feature/dev 13474 kaniko braid (#24)

* initial build

* initial build

* attempting to implement pod template

* updated code adding braid pod template
This commit is contained in:
Jarred Hunter 2022-03-16 14:06:16 -05:00 committed by GitHub
parent ce2c65544c
commit c8e4b690c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

81
Jenkinsfile vendored
View File

@ -1,46 +1,51 @@
def label = "node-${UUID.randomUUID().toString()}" pipeline {
agent {
podTemplate(label: label, inheritFrom: 'base', , containers: [ kubernetes {
containerTemplate(name: 'base', image: 'taylorchristieyardstick/build-base:node') label "kaniko-${UUID.randomUUID()}"
]) { inheritFrom 'kaniko'
node(label) { containerTemplate {
stage('Checkout Project') { name 'braid'
container('base') { image 'node:8'
command 'sleep 9999'
}
}
}
environment {
REPOSITORY = "yardstick/braid"
}
stages {
stage('Exec NPM commands') {
steps {
container('braid') {
checkout scm checkout scm
sh 'npm install'
sh 'npm install typescript'
sh 'npx tsc'
sh 'npm test'
} }
} }
stage('Install Dependencies') {
container('base') {
sh "npm install"
sh "npm install typescript"
} }
} stage('Build with Kaniko') {
stage('Build the Project') { steps {
container('base') {
sh "npx tsc"
}
}
stage('Run unit tests') {
container('base') {
sh "npm test"
}
}
stage('Login to Dockerhub') {
withCredentials([usernamePassword(credentialsId: 'DockerHubAccessYardstick', usernameVariable: 'USER', passwordVariable: 'PASS')]) { withCredentials([usernamePassword(credentialsId: 'DockerHubAccessYardstick', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
container('base') { container('kaniko') {
sh "docker login --username ${USER} --password ${PASS}" 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
stage('Build the Docker Image') { sh """
container('base') { /kaniko/executor -f `pwd`/Dockerfile \
sh "make build branch=${BRANCH_NAME}" -c `pwd` \
} --insecure=true \
} --insecure-registry=docker-registry.default:5000 \
--cache=true \
stage('Push the Docker Image') { --cache-repo=docker-registry.default:5000/${env.REPOSITORY} \
container('base') { --destination ${env.REPOSITORY}:\$(echo ${BRANCH_NAME} | grep -Eo 'feature/([A-Za-z]+-[0-9]*)' | grep -Eo '[A-Za-z]+-[0-9]*' || \
sh "make push branch=${BRANCH_NAME}" echo ${BRANCH_NAME} | grep -Eo '(release|hotfix)/[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+' | grep -Eo '[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+' || \
echo ${BRANCH_NAME} | grep -Eo 'YASDEV-([[:digit:]]*)')
"""
}
}
} }
} }
} }