Skip to content

Commit

Permalink
HSEARCH-4924 Mark stages as skipped if nothing gets built due to incr…
Browse files Browse the repository at this point in the history
…emental build
  • Loading branch information
yrodiere committed Aug 28, 2023
1 parent 42e56e7 commit bd5df7a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,12 @@ void mavenNonDefaultBuild(BuildEnvironment buildEnv, String args, List<String> a
// We want to run relevant integration test modules only (see array of module names)
// and in PRs we want to run only those affected by changes
// (see gib.disableSelectedProjectsHandling=true).
String incrementalProjectsListFile = 'target/.gib-impacted'
String argsWithProjectSelection = """ \
${incrementalBuild ? """ \
-Dincremental -Dgib.disableSelectedProjectsHandling=true \
-Dgib.referenceBranch=refs/remotes/origin/${helper.scmSource.pullRequest.target.name} \
-Dgib.logImpactedTo='${incrementalProjectsListFile}' \
""" : ''} \
${args} \
"""
Expand All @@ -924,6 +926,15 @@ void mavenNonDefaultBuild(BuildEnvironment buildEnv, String args, List<String> a
--fail-at-end \
$argsWithProjectSelection \
"""

// In incremental builds, the Maven execution above
// created a file listing projects relevant to the incremental build.
// If it is empty, it means the incremental build didn't actually do anything,
// so make sure to mark the stage as skipped.
if (incrementalBuild && 0 == sh(script: "test ! -s '${incrementalProjectsListFile}'", returnStatus: true)) {
echo 'Skipping stage because PR changes do not affect tested modules'
helper.markStageSkipped()
}
}

String toTestJdkArg(BuildEnvironment buildEnv) {
Expand Down

0 comments on commit bd5df7a

Please sign in to comment.