Jenkins file fix

This commit is contained in:
cghislai 2021-02-14 21:27:36 +01:00
parent 38a1ca1c80
commit 3df67f9c19
2 changed files with 42 additions and 16 deletions

48
Jenkinsfile vendored
View File

@ -6,9 +6,19 @@ pipeline {
}
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_TAG', defaultValue: 'docker.charlyghislain.com/charlyghislaindotcom',
description: 'Image tag to push'
name: 'IMAGE', defaultValue: 'charlyghislaindotcom',
description: 'Image to push (suffixed -fr or -en)'
)
string(
name: 'REPO', defaultValue: 'docker.charlyghislain.com',
description: 'Repo to push'
)
credentials(
name: 'REPO_USERNAMEPASS_CREDENTIAL', defaultValue: 'jenkins-jenkins-nexus-credentials',
description: 'Cred for repo', credentialType: "Username with password"
)
}
stages {
@ -34,27 +44,43 @@ pipeline {
}
}
stage ('Publish') {
when {
expression { return params.SKIP_PUBLISH != true }
}
agent {
label 'docker'
}
steps {
container('docker') {
unstash(name: 'dist')
sh '''
export COMMIT="$(git rev-parse --short HEAD)"
docker build --build-arg CLANG=fr -t "${IMAGE_TAG}-fr:${COMMIT}" .
docker push "${IMAGE_TAG}-fr:${COMMIT}" .
docker build --build-arg CLANG=en -t "${IMAGE_TAG}-en:${COMMIT}" .
docker push "${IMAGE_TAG}-en:${COMMIT}" .
'''
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 params.SKIP_PUBLISH != true }
expression { return params.SKIP_CLUSTER_UPDATE != true }
}
}
steps {
build job: 'infra/cluster-conf-update', parameters: [
string(name:"STACK", value:"charlyghislaindotcom"),
string(name:"VALUES_FILE", value:"values.yaml"),
string(name:"VALUES_KEY", value:".deployment.imageTag"),
string(name:"VALUES_VALUE", value:"\"${env.COMMIT}\""),
string(name:"VALUES_VALUE", value:"\"${VERSION}\""),
]
}
}
}
}
}

View File

@ -3,7 +3,7 @@ multibranchPipelineJob('charlyghislaindotcom/charlyghislaindotcom') {
branchSource {
source {
git {
id('lifeislife_lifeislife-front_repo') // IMPORTANT: use a constant and unique identifier
id('charlyghislaindotcom-front_repo') // IMPORTANT: use a constant and unique identifier
remote('ssh://git@gitea.charlyghislain.com:2022/cghislai/charlyghislaindotcom.git')
credentialsId('jenkins-jenkins-ssh-key')
traits {