88 lines
2.7 KiB
Plaintext
88 lines
2.7 KiB
Plaintext
|
pipeline {
|
||
|
agent any
|
||
|
|
||
|
environment {
|
||
|
NEXUS = credentials('jenkins_nexus')
|
||
|
NCLAZZ = credentials('nclazz_api_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"
|
||
|
|
||
|
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 {
|
||
|
deployToSwarm(
|
||
|
name: 'nclazz-gitea-bot',
|
||
|
file: "${env.WORKSPACE}/docker-compose.yml",
|
||
|
forceUpdate: true,
|
||
|
askApproval: false,
|
||
|
slackChannel: 'deployment',
|
||
|
env: [
|
||
|
PORT: 7007,
|
||
|
VERSION: env.DOCKER_VERSION,
|
||
|
AUTH_TOKEN: env.NCLAZZ
|
||
|
]
|
||
|
)
|
||
|
exposeService(
|
||
|
name: 'nclazz-gitea-bot',
|
||
|
fqdn: 'gitea-bot.nclazz.de',
|
||
|
description: 'Gitea bot',
|
||
|
location: '/',
|
||
|
backendPort: 7007
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
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} "
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
}
|