
* initial build * initial build * attempting to implement pod template * updated code adding braid pod template
52 lines
1.8 KiB
Groovy
52 lines
1.8 KiB
Groovy
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('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:]]*)')
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |