diff --git a/first-class-pipeline/src/com/freeleaps/devops/SemanticReleasingExecutor.groovy b/first-class-pipeline/src/com/freeleaps/devops/SemanticReleasingExecutor.groovy index 9bdff998..239fda17 100644 --- a/first-class-pipeline/src/com/freeleaps/devops/SemanticReleasingExecutor.groovy +++ b/first-class-pipeline/src/com/freeleaps/devops/SemanticReleasingExecutor.groovy @@ -26,11 +26,7 @@ class SemanticReleasingExecutor { steps.dir(steps.env.workroot) { steps.withCredentials([steps.usernamePassword(credentialsId: credentialsId, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { steps.env.GIT_CREDENTIALS = "${steps.env.GIT_USERNAME}:${steps.env.GIT_PASSWORD}" - // steps.log.info("SemanticReleasingExecutor", "Installing semantic-release requirements...") - // steps.sh "apt-get -y update && apt-get install -y --no-install-recommends git apt-transport-https ca-certificates curl wget gnupg" steps.writeFile file: '.releaserc.json', text: steps.libraryResource(config) - // steps.log.info("SemanticReleasingExecutor", "Installing semantic-release plugins...") - // steps.sh "npm install -g ${plugins.join(' ')}" steps.sh "git config --global --add safe.directory ${steps.env.workroot}" steps.env.GIT_LOCAL_BRANCH = "${branch}" steps.sh """ @@ -38,10 +34,23 @@ class SemanticReleasingExecutor { semantic-release """ steps.log.info("SemanticReleasingExecutor", "Semantic release completed, read latest version from VERSION file") - def released = steps.sh(script: 'test -f "VERSION"', returnStatus: true) == 0 + + // check if VERSION file exists + def versionFileExists = steps.sh(script: 'test -f "VERSION"', returnStatus: true) == 0 + def recentlyModified = false + if (versionFileExists) { + // check if VERSION file was modified recently (within last minute) + def recentlyModified = steps.sh(script: 'stat -c %Y "VERSION"', returnStdout: true).trim() as Long + def currentTime = System.currentTimeMillis() / 1000 + recentlyModified = (currentTime - recentlyModified) < 60 + } + + def released = fileExists && recentlyModified if (released) { steps.env.LATEST_VERSION = steps.readFile('VERSION').trim() steps.env.SEMANTIC_RELEASED = true + } else if (versionFileExists) { + steps.log.warn("SemanticReleasingExecutor", "VERSION file exists but was not modified recently, skipping release") } } } diff --git a/freeleaps/alpha/ci/freeleaps-service-hub/Jenkinsfile b/freeleaps/alpha/ci/freeleaps-service-hub/Jenkinsfile index f90067d3..4a9cb14d 100644 --- a/freeleaps/alpha/ci/freeleaps-service-hub/Jenkinsfile +++ b/freeleaps/alpha/ci/freeleaps-service-hub/Jenkinsfile @@ -7,7 +7,7 @@ executeFreeleapsPipeline { serviceGitRepo = "https://gitea.freeleaps.mathmast.com/freeleaps/freeleaps-service-hub.git" serviceGitRepoType = 'monorepo' serviceGitCredentialsId = 'freeleaps-repos-gitea-credentails' - executeMode = 'on-demand' + executeMode = 'fully' commitMessageLintEnabled = false components = [ [