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:
parent
ce2c65544c
commit
c8e4b690c5
81
Jenkinsfile
vendored
81
Jenkinsfile
vendored
@ -1,46 +1,51 @@
|
||||
def label = "node-${UUID.randomUUID().toString()}"
|
||||
|
||||
podTemplate(label: label, inheritFrom: 'base', , containers: [
|
||||
containerTemplate(name: 'base', image: 'taylorchristieyardstick/build-base:node')
|
||||
]) {
|
||||
node(label) {
|
||||
stage('Checkout Project') {
|
||||
container('base') {
|
||||
pipeline {
|
||||
agent {
|
||||
kubernetes {
|
||||
label "kaniko-${UUID.randomUUID()}"
|
||||
inheritFrom 'kaniko'
|
||||
containerTemplate {
|
||||
name 'braid'
|
||||
image 'node:8'
|
||||
command 'sleep 9999'
|
||||
}
|
||||
}
|
||||
}
|
||||
environment {
|
||||
REPOSITORY = "yardstick/braid"
|
||||
}
|
||||
stages {
|
||||
stage('Exec NPM commands') {
|
||||
steps {
|
||||
container('braid') {
|
||||
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 the Project') {
|
||||
container('base') {
|
||||
sh "npx tsc"
|
||||
}
|
||||
}
|
||||
stage('Run unit tests') {
|
||||
container('base') {
|
||||
sh "npm test"
|
||||
}
|
||||
}
|
||||
stage('Login to Dockerhub') {
|
||||
stage('Build with Kaniko') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'DockerHubAccessYardstick', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
|
||||
container('base') {
|
||||
sh "docker login --username ${USER} --password ${PASS}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build the Docker Image') {
|
||||
container('base') {
|
||||
sh "make build branch=${BRANCH_NAME}"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push the Docker Image') {
|
||||
container('base') {
|
||||
sh "make push branch=${BRANCH_NAME}"
|
||||
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/${env.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:]]*)')
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user