gitea-bot/Jenkinsfile

76 lines
2.3 KiB
Plaintext
Raw Normal View History

2022-07-08 23:05:36 +02:00
pipeline {
agent any
environment {
NEXUS = credentials('jenkins_nexus')
NCLAZZ = credentials('nclazz_api_token')
2022-07-09 00:43:40 +02:00
GITEA_TOKEN = credentials('jenkins_gitea_token')
2022-07-08 23:05:36 +02:00
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"
2022-11-28 13:40:55 +01:00
KUBECONFIG = "/etc/k8s/nclazz"
2022-07-08 23:05:36 +02:00
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 {
2022-11-28 13:54:45 +01:00
sh "helm upgrade --install giteabot ./charts \
--create-namespace --namespace nclazz \
--set nclazz_token=${NCLAZZ} \
2022-11-28 13:55:21 +01:00
--set gitea_token=${GITEA_TOKEN}"
2022-07-08 23:05:36 +02:00
}
}
}
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} "
)
}
}
}