Skip to content

Commit 56aa817

Browse files
committed
[Build] Skip scheduled I/Y-build if nothing has changed since last build
Fixes #678
1 parent 53071c7 commit 56aa817

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

JenkinsJobs/Builds/I_build.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ spec:
208208
}
209209
}
210210
stage('Tag Build Inputs'){
211+
environment {
212+
ABORT_IF_NO_CHANGES = "${!currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').isEmpty()}" // true, if triggered by timer
213+
}
211214
steps {
212215
sshagent (['git.eclipse.org-bot-ssh', 'github-bot-ssh', 'projects-storage.eclipse.org-bot-ssh']) {
213216
sh \'\'\'
@@ -220,6 +223,16 @@ spec:
220223
fi
221224
\'\'\'
222225
}
226+
script {
227+
if (env.ABORT_IF_NO_CHANGES && fileExists("${WORKSPACE}/noChanges")) {
228+
emailext subject: "${env.BUILD_VERSION} I-Build: ${env.BUILD_IID.trim()} - BUILD SKIPPED",
229+
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>",
230+
231+
232+
currentBuild.result = 'ABORTED'
233+
error('Abort scheduled build due to no changes')
234+
}
235+
}
223236
}
224237
}
225238
stage('Aggregator maven build'){

JenkinsJobs/YBuilds/Y_build.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ spec:
205205
}
206206
}
207207
stage('Tag Build Inputs'){
208+
environment {
209+
ABORT_IF_NO_CHANGES = "${!currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').isEmpty()}" // true, if triggered by timer
210+
}
208211
steps {
209212
sshagent (['git.eclipse.org-bot-ssh', 'github-bot-ssh', 'projects-storage.eclipse.org-bot-ssh']) {
210213
sh \'\'\'
@@ -217,6 +220,16 @@ spec:
217220
fi
218221
\'\'\'
219222
}
223+
script {
224+
if (env.ABORT_IF_NO_CHANGES && fileExists("${WORKSPACE}/noChanges")) {
225+
emailext subject: "${env.BUILD_VERSION} I-Build: ${env.BUILD_IID.trim()} - BUILD SKIPPED",
226+
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>",
227+
228+
229+
currentBuild.result = 'ABORTED'
230+
error('Abort scheduled build due to no changes')
231+
}
232+
}
220233
}
221234
}
222235
stage('Aggregator maven build'){

cje-production/mbscripts/mb110_tagBuildInputs.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ fi
4646

4747
pushd $CJE_ROOT/$AGG_DIR
4848

49+
if $ABORT_IF_NO_CHANGES;then
50+
listChangesInRepo="git diff ${lastTag}..HEAD --name-only"
51+
if [[ -z $(${listChangesInRepo}) && -z $(git submodule --quiet foreach ${listChangesInRepo}) ]];then
52+
echo "No changes in git repository since : ${lastTag}"
53+
touch "${WORKSPACE}/noChanges"
54+
exit 0
55+
fi
56+
fi
57+
4958
# git tagging
5059
if [ "${BUILD_TYPE}" == "I" ]
5160
then

0 commit comments

Comments
 (0)