Skip to content

Commit

Permalink
build for testing purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
zingmane committed May 13, 2024
1 parent c46f55b commit 3a0444e
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
IMAGE_NAME = "campudus/grud-backend"
DEPLOY_DIR = 'build/libs'
LEGACY_ARCHIVE_FILENAME="grud-backend-docker.tar.gz"
DOCKER_BASE_IMAGE_TAG = "build-${BUILD_NUMBER}"
DOCKER_BASE_IMAGE_TAG = "build-branch-${BUILD_NUMBER}"

SLACK_CHANNEL = "#grud"
// SLACK_CHANNEL = "#grud"

// flag deactivate tests for fast redeployment from jenkins frontend
shouldTest = true
shouldTest = false

pipeline {
agent any
Expand Down Expand Up @@ -85,47 +85,22 @@ pipeline {
--label "GIT_COMMIT_DATE=${GIT_COMMIT_DATE}" \
--label "BUILD_DATE=${BUILD_DATE}" \
-t ${IMAGE_NAME}:${DOCKER_BASE_IMAGE_TAG}-${GIT_COMMIT} \
-t ${IMAGE_NAME}:latest \
-f Dockerfile \
--rm --target=prod .
"""
// Legacy, but needed for some project deployments
sh "docker save ${IMAGE_NAME}:latest | gzip -c > ${DEPLOY_DIR}/${LEGACY_ARCHIVE_FILENAME}"
}
}

stage('Archive artifacts') {
steps {
archiveArtifacts artifacts: "${DEPLOY_DIR}/*-fat.jar", fingerprint: true
archiveArtifacts artifacts: "${DEPLOY_DIR}/${LEGACY_ARCHIVE_FILENAME}", fingerprint: true
}
}

stage('Push to docker registry') {
steps {
withDockerRegistry([ credentialsId: "dockerhub", url: "" ]) {
sh "docker push ${IMAGE_NAME}:${DOCKER_BASE_IMAGE_TAG}-${GIT_COMMIT}"
sh "docker push ${IMAGE_NAME}:latest"
}
}
}
}

post {
success {
wrap([$class: 'BuildUser']) {
script {
sh "echo successful"
slackOk(channel: SLACK_CHANNEL, message: "Image pushed to docker registry: ${IMAGE_NAME}:${DOCKER_BASE_IMAGE_TAG}-${GIT_COMMIT}")
}
}
}

failure {
wrap([$class: 'BuildUser']) {
script {
sh "echo failed"
slackError(channel: SLACK_CHANNEL)
}
}
}
Expand Down

0 comments on commit 3a0444e

Please sign in to comment.