Skip to content

Commit

Permalink
Add docker build test
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinab25 committed Sep 23, 2021
1 parent 436b1e6 commit d70f2d8
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ pipeline {
SONARQUBE_TAG = ""
}



stages {

stage('Integration tests') {
steps {

stage('Integration tests') {
parallel {
stage('Cypress') {
steps {
node(label: 'docker') {
script {
try {
Expand All @@ -41,8 +45,40 @@ pipeline {
}
}
}
}
}

stage("Docker test build") {
when {
not {
environment name: 'CHANGE_ID', value: ''
}
not {
buildingTag()
}
environment name: 'CHANGE_TARGET', value: 'master'
}
environment {
IMAGE_NAME = BUILD_TAG.toLowerCase()
}
steps {
node(label: 'docker-host') {
script {
checkout scm
try {
dockerImage = docker.build("${IMAGE_NAME}", "--no-cache .")
} finally {
sh script: "docker rmi ${IMAGE_NAME}", returnStatus: true
}
}
}
}
}


}
}


stage('Pull Request') {
when {
Expand Down Expand Up @@ -116,9 +152,9 @@ pipeline {
}
steps{
node(label: 'docker') {
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
sh '''docker pull eeacms/gitflow; docker run -i --rm --name="${BUILD_TAG}-release" -e GIT_TOKEN="${GITHUB_TOKEN}" -e RANCHER_CATALOG_PATH="${template}" -e DOCKER_IMAGEVERSION="${BRANCH_NAME}" -e DOCKER_IMAGENAME="${registry}" --entrypoint /add_rancher_catalog_entry.sh eeacms/gitflow'''
}
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'), usernamePassword(credentialsId: 'jekinsdockerhub', usernameVariable: 'DOCKERHUB_USER', passwordVariable: 'DOCKERHUB_PASS')]) {
sh '''docker pull eeacms/gitflow; docker run -i --rm --name="$BUILD_TAG-release" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e DOCKERHUB_REPO="$registry" -e GIT_TOKEN="$GITHUB_TOKEN" -e DOCKERHUB_USER="$DOCKERHUB_USER" -e DOCKERHUB_PASS="$DOCKERHUB_PASS" -e RANCHER_CATALOG_PATHS="$template" -e GITFLOW_BEHAVIOR="RUN_ON_TAG" eeacms/gitflow'''
}
}
}
}
Expand Down Expand Up @@ -158,6 +194,7 @@ pipeline {
}
}


post {
always {
cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true)
Expand Down

0 comments on commit d70f2d8

Please sign in to comment.