Skip to content

Commit

Permalink
HSEARCH-5094 Make the build env tag available in Develocity on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Mar 1, 2024
1 parent a6ed184 commit f25d415
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ stage('Default build') {
String commonMavenArgs = """ \
--fail-at-end \
-Pcoverage \
${toTestJdkArg(environments.content.jdk.default)} \
${toTestEnvironmentArgs(environments.content.jdk.default)} \
"""

echo "Building code and running unit tests and basic checks."
Expand Down Expand Up @@ -963,14 +963,10 @@ void mavenNonDefaultBuild(BuildEnvironment buildEnv, String args, List<String> a

pullContainerImages( args )

// Add a suffix to tests to distinguish between different executions
// of the same test in different environments in reports
def testSuffix = buildEnv.tag.replaceAll('[^a-zA-Z0-9_\\-+]+', '_')

// Note "clean" is necessary here in order to store the result of the build in the remote build cache
sh """ \
mvn clean install -Pci-build -Dsurefire.environment=$testSuffix \
${toTestJdkArg(buildEnv)} \
mvn clean install -Pci-build \
${toTestEnvironmentArgs(buildEnv)} \
--fail-at-end \
$args \
"""
Expand All @@ -985,9 +981,16 @@ void mavenNonDefaultBuild(BuildEnvironment buildEnv, String args, List<String> a
}
}

String toTestJdkArg(BuildEnvironment buildEnv) {
String toTestEnvironmentArgs(BuildEnvironment buildEnv) {
String args = ''

// Make the build env tag available in Develocity
args += "-Dscan.tag.${buildEnv.tag}"
// Add a suffix to tests to distinguish between different executions
// of the same test in different environments in reports
def testSuffix = buildEnv.tag.replaceAll('[^a-zA-Z0-9_\\-+]+', '_')
args += "-Dsurefire.environment=$testSuffix"

if ( ! (buildEnv instanceof JdkBuildEnvironment) ) {
return args;
}
Expand Down

0 comments on commit f25d415

Please sign in to comment.