Skip to content

Commit

Permalink
[Build] Skip scheduled I/Y-build if nothing has changed since last build
Browse files Browse the repository at this point in the history
Fixes #678
  • Loading branch information
HannesWell committed Dec 27, 2024
1 parent 53071c7 commit 56aa817
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions JenkinsJobs/Builds/I_build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ spec:
}
}
stage('Tag Build Inputs'){
environment {
ABORT_IF_NO_CHANGES = "${!currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').isEmpty()}" // true, if triggered by timer
}
steps {
sshagent (['git.eclipse.org-bot-ssh', 'github-bot-ssh', 'projects-storage.eclipse.org-bot-ssh']) {
sh \'\'\'
Expand All @@ -220,6 +223,16 @@ spec:
fi
\'\'\'
}
script {
if (env.ABORT_IF_NO_CHANGES && fileExists("${WORKSPACE}/noChanges")) {
emailext subject: "${env.BUILD_VERSION} I-Build: ${env.BUILD_IID.trim()} - BUILD SKIPPED",
body: "The scheduled build was skipped because no changes have been made since the last successful build.<br>For details see <a href='${BUILD_URL}console'>${BUILD_URL}console</a><br>",
to: '[email protected]',
from: '[email protected]'
currentBuild.result = 'ABORTED'
error('Abort scheduled build due to no changes')
}
}
}
}
stage('Aggregator maven build'){
Expand Down
13 changes: 13 additions & 0 deletions JenkinsJobs/YBuilds/Y_build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ spec:
}
}
stage('Tag Build Inputs'){
environment {
ABORT_IF_NO_CHANGES = "${!currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').isEmpty()}" // true, if triggered by timer
}
steps {
sshagent (['git.eclipse.org-bot-ssh', 'github-bot-ssh', 'projects-storage.eclipse.org-bot-ssh']) {
sh \'\'\'
Expand All @@ -217,6 +220,16 @@ spec:
fi
\'\'\'
}
script {
if (env.ABORT_IF_NO_CHANGES && fileExists("${WORKSPACE}/noChanges")) {
emailext subject: "${env.BUILD_VERSION} I-Build: ${env.BUILD_IID.trim()} - BUILD SKIPPED",
body: "The scheduled build was skipped because no changes have been made since the last successful build.<br>For details see <a href='${BUILD_URL}console'>${BUILD_URL}console</a><br>",
to: '[email protected]',
from: '[email protected]'
currentBuild.result = 'ABORTED'
error('Abort scheduled build due to no changes')
}
}
}
}
stage('Aggregator maven build'){
Expand Down
9 changes: 9 additions & 0 deletions cje-production/mbscripts/mb110_tagBuildInputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ fi

pushd $CJE_ROOT/$AGG_DIR

if $ABORT_IF_NO_CHANGES;then
listChangesInRepo="git diff ${lastTag}..HEAD --name-only"
if [[ -z $(${listChangesInRepo}) && -z $(git submodule --quiet foreach ${listChangesInRepo}) ]];then
echo "No changes in git repository since : ${lastTag}"
touch "${WORKSPACE}/noChanges"
exit 0
fi
fi

# git tagging
if [ "${BUILD_TYPE}" == "I" ]
then
Expand Down

0 comments on commit 56aa817

Please sign in to comment.