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
93
Jenkinsfile
vendored
93
Jenkinsfile
vendored
@ -1,47 +1,52 @@
|
|||||||
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'
|
||||||
checkout scm
|
command 'sleep 9999'
|
||||||
}
|
|
||||||
}
|
|
||||||
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') {
|
|
||||||
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}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
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('Build with Kaniko') {
|
||||||
|
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/${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