This commit is contained in:
73
Jenkinsfile
vendored
Normal file
73
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
def FAILED_STAGE
|
||||
|
||||
pipeline {
|
||||
environment {
|
||||
registry = "git.letsstein.de/tom"
|
||||
registryCredential = 'gitea_docker_tom'
|
||||
image = getImageName("mqtt_creator", env.BRANCH_NAME)
|
||||
}
|
||||
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Building image') {
|
||||
when {
|
||||
anyOf{
|
||||
changeset "src/**"
|
||||
changeset "Dockerfile"
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
FAILED_STAGE=env.STAGE_NAME
|
||||
image = docker.build "$registry/$image:$BUILD_NUMBER"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Deploying homepage image'){
|
||||
when {
|
||||
anyOf{
|
||||
changeset "src/**"
|
||||
changeset "Dockerfile"
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
FAILED_STAGE=env.STAGE_NAME
|
||||
docker.withRegistry("https://$registry", registryCredential){
|
||||
image.push()
|
||||
image.push("latest")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'One way or another, I have finished'
|
||||
// deleteDir() /* clean up our workspace */
|
||||
}
|
||||
success {
|
||||
echo 'I succeeded!'
|
||||
httpRequest authentication: 'ntfy-tom',
|
||||
contentType: 'TEXT_PLAIN',
|
||||
httpMode: 'POST', quiet: true,
|
||||
requestBody: "MQTT_CREATOR: Build $BUILD_NUMBER auf $BRANCH_NAME erfolgreich hochgeladen",
|
||||
url: 'https://apintfy.tomtroeger.de/sylNAsGkA5FhtXK9'
|
||||
}
|
||||
failure {
|
||||
echo 'I failed :('
|
||||
httpRequest authentication: 'ntfy-tom',
|
||||
contentType: 'TEXT_PLAIN',
|
||||
httpMode: 'POST', quiet: true,
|
||||
requestBody: "MQTT_CREATOR: Fehler bei Build $BUILD_NUMBER auf $BRANCH_NAME . Fehler bei Stage $FAILED_STAGE",
|
||||
url: 'https://apintfy.tomtroeger.de/sylNAsGkA5FhtXK9'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getImageName(imgname, branchName) {
|
||||
if("main".equals(branchName)){
|
||||
return imgname;
|
||||
}else return imgname + "-test";
|
||||
}
|
||||
Reference in New Issue
Block a user