Update Jenkinsfile

This commit is contained in:
2025-05-27 15:34:51 +03:00
parent f88e519ad7
commit cb5b38d920

24
Jenkinsfile vendored
View File

@@ -16,6 +16,30 @@ pipeline {
}
}
}
stage('Check First Pipeline Status') {
steps {
script {
def jobName = "custom-dind-pipeline"
def jobURL = "http://jenkins-server.default.svc.cluster.local:8080/job/${jobName}/api/json"
// Fetch the raw JSON response
def response = sh(script: "curl -s ${jobURL}", returnStdout: true).trim()
// Parse JSON using Groovy's built-in JSON handling
def jsonSlurper = new groovy.json.JsonSlurper()
def jobData = jsonSlurper.parseText(response)
// Extract the first build number to check if the job has run at least once
def firstBuildNumber = jobData.firstBuild?.number
if (firstBuildNumber == null) {
error("Pipeline '${jobName}' has **never** run! Stopping execution.")
}
echo "Pipeline '${jobName}' has executed before. First build number: ${firstBuildNumber}"
}
}
}
stage('Build and Deploy') {
steps {
script {