All checks were successful
charlyghislain/charlyghislaindotcom/pipeline/head This commit looks good
85 lines
3.1 KiB
Groovy
85 lines
3.1 KiB
Groovy
pipeline {
|
|
agent any
|
|
options {
|
|
disableConcurrentBuilds()
|
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
|
}
|
|
parameters {
|
|
booleanParam(name: 'SKIP_TESTS', defaultValue: true, description: 'Skip tests')
|
|
booleanParam(name: 'SKIP_PUBLISH', defaultValue: false, description: 'Skip docker image build&push')
|
|
booleanParam(name: 'SKIP_CLUSTER_UPDATE', defaultValue: false, description: 'Skip cluster state repo commit')
|
|
string(
|
|
name: 'IMAGE', defaultValue: 'charlyghislaindotcom',
|
|
description: 'Image to push (suffixed -fr or -en)'
|
|
)
|
|
string(
|
|
name: 'REPO', defaultValue: 'docker.valuya.com',
|
|
description: 'Repo to push'
|
|
)
|
|
credentials(
|
|
name: 'REPO_USERNAMEPASS_CREDENTIAL', defaultValue: 'jenkins-jenkins-nexus-credentials',
|
|
description: 'Cred for repo', credentialType: "Username with password"
|
|
)
|
|
}
|
|
stages {
|
|
stage ('Build') {
|
|
steps {
|
|
nodejs(nodeJSInstallationName: 'node 16', configId: 'npm-global-config') { catchError {
|
|
ansiColor('xterm') {
|
|
sh '''
|
|
rm -rfv dist*
|
|
npm ci
|
|
|
|
export DATE="$(date -Iseconds)"
|
|
export COMMIT="$(git rev-parse --short HEAD)"
|
|
echo '{"date":"'$DATE'","commit": "'$COMMIT'"}' > src/assets/buildinfo.json
|
|
|
|
./node_modules/.bin/ng build -c "production-fr"
|
|
./node_modules/.bin/ng build -c "production-en"
|
|
echo "$COMMIT" > dist/.version
|
|
'''
|
|
}
|
|
}}
|
|
stash(name: 'dist', includes: 'dist/**')
|
|
}
|
|
}
|
|
stage ('Publish') {
|
|
when {
|
|
expression { return params.SKIP_PUBLISH != true }
|
|
}
|
|
agent {
|
|
label 'docker'
|
|
}
|
|
steps {
|
|
container('docker') {
|
|
unstash(name: 'dist')
|
|
script {
|
|
VERSION = sh(script: 'head -n1 dist/.version', returnStdout: true).trim()
|
|
def fr = docker.build("${params.REPO}/${params.IMAGE}-fr:${VERSION}", "--build-arg CLANG=fr .")
|
|
def en = docker.build("${params.REPO}/${params.IMAGE}-en:${VERSION}", "--build-arg CLANG=en .")
|
|
|
|
fr.push()
|
|
fr.push('latest')
|
|
en.push()
|
|
en.push('latest')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage ('Update cluster') {
|
|
when {
|
|
allOf {
|
|
expression { return env.BRANCH_NAME == 'master' }
|
|
expression { return params.SKIP_PUBLISH != true }
|
|
expression { return params.SKIP_CLUSTER_UPDATE != true }
|
|
}
|
|
}
|
|
steps {
|
|
build job: 'cghislai-releases/charlyghislaindotcom-release/master', parameters: [
|
|
string(name:"IMAGE_TAG", value:"\"${VERSION}\""),
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|