76 lines
2.3 KiB
Groovy
76 lines
2.3 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
environment {
|
|
NEXUS = credentials('jenkins_nexus')
|
|
NCLAZZ = credentials('nclazz_api_token')
|
|
GITEA_TOKEN = credentials('jenkins_gitea_token')
|
|
|
|
DOCKER_REGISTRY = "docker.nclazz.de"
|
|
DOCKER_GROUP = 'nclazz-bots'
|
|
DOCKER_IMAGE = 'gitea-bot'
|
|
DOCKER_TAG = "${ BRANCH_NAME == "master" ? "latest" : "develop" }"
|
|
DOCKER_VERSION = "1.0.0"
|
|
|
|
KUBECONFIG = "/etc/k8s/nclazz"
|
|
|
|
DEPLOY_ENV = "production"
|
|
}
|
|
|
|
options {
|
|
timeout(time: 30, unit: "MINUTES")
|
|
}
|
|
|
|
stages {
|
|
stage('Docker Build') {
|
|
agent { label 'docker' }
|
|
steps {
|
|
script {
|
|
docker.withRegistry("https://$DOCKER_REGISTRY", "jenkins_nexus") {
|
|
def apiImage = docker.build("$DOCKER_GROUP/$DOCKER_IMAGE")
|
|
apiImage.push("${env.DOCKER_VERSION}")
|
|
apiImage.push("${env.DOCKER_TAG}")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Run Deployment') {
|
|
agent { label 'provision' }
|
|
when {
|
|
branch 'master'
|
|
}
|
|
steps {
|
|
sh "helm upgrade --install giteabot ./charts \
|
|
--create-namespace --namespace nclazz \
|
|
--set nclazz_token=${NCLAZZ} \
|
|
--set gitea_token=${GITEA_TOKEN}"
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
cleanWs()
|
|
}
|
|
failure {
|
|
slackSend(
|
|
channel: "notifications",
|
|
color: "danger",
|
|
message: "There is a *build failure* in ${env.JOB_NAME}.\nBuild: ${env.RUN_DISPLAY_URL} "
|
|
)
|
|
}
|
|
unstable {
|
|
slackSend(
|
|
channel: "notifications",
|
|
color: "warning",
|
|
message: "Some tests have failed in ${env.JOB_NAME}.\nBuild: ${env.RUN_DISPLAY_URL} "
|
|
)
|
|
}
|
|
fixed {
|
|
slackSend(
|
|
channel: "notifications",
|
|
color: "good",
|
|
message: "The build ${env.JOB_NAME} completed successfully and is back to normal.\nBuild: ${env.RUN_DISPLAY_URL} "
|
|
)
|
|
}
|
|
}
|
|
} |