File tree Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -21,21 +21,8 @@ steps:
2121- checkout : self
2222 fetchDepth : 2
2323
24- # Set the SKIP_JOB environment variable if this job is supposed to only run
25- # when submodules are updated and they were not. The following time consuming
26- # tasks will be skipped when the environment variable is present.
27- - bash : |
28- set -e
29- # Submodules pseudo-files inside git have the 160000 permissions, so when
30- # those files are present in the diff a submodule was updated.
31- if git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then
32- echo "Executing the job since submodules are updated"
33- else
34- echo "Not executing this job since no submodules were updated"
35- echo "##vso[task.setvariable variable=SKIP_JOB;]1"
36- fi
24+ - bash : src/ci/scripts/should-skip-this.sh
3725 displayName : Decide whether to run this job
38- condition : and(succeeded(), variables.CI_ONLY_WHEN_SUBMODULES_CHANGED)
3926
4027# Spawn a background process to collect CPU usage statistics which we'll upload
4128# at the end of the build. See the comments in the script here for more
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Set the SKIP_JOB environment variable if this job is supposed to only run
3+ # when submodules are updated and they were not. The following time consuming
4+ # tasks will be skipped when the environment variable is present.
5+
6+ set -euo pipefail
7+ IFS=$' \n\t '
8+
9+ source " $( cd " $( dirname " $0 " ) " && pwd) /../shared.sh"
10+
11+ if [[ -z " ${CI_ONLY_WHEN_SUBMODULES_CHANGED+x} " ]]; then
12+ echo " Executing the job since there is no skip rule in effect"
13+ elif git diff HEAD^ | grep " ^index .* 160000" > /dev/null 2>&1 ; then
14+ # Submodules pseudo-files inside git have the 160000 permissions, so when
15+ # those files are present in the diff a submodule was updated.
16+ echo " Executing the job since submodules are updated"
17+ else
18+ echo " Not executing this job since no submodules were updated"
19+ ciCommandSetEnv SKIP_JOB 1
20+ fi
You can’t perform that action at this time.
0 commit comments