Skip to content

Commit

Permalink
chore(pipeline) Limit Docker API rate limit when testing (jenkinsci#1640
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dduportal authored Jul 26, 2024
1 parent c4fa3e5 commit 71de485
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ stage('Record builds and sessions') {
}
axes['jenkinsVersions'].each { jenkinsVersion ->
infra.withArtifactCachingProxy {
// Need to authenticate on DockerHub with a read-only account to avoid rate limit
infra.withDockerCredentials {
sh "rm -rf target && DISPLAY=:0 ./run.sh firefox ${jenkinsVersion} -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo -B clean process-test-resources"
}
}
def coreCommit = sh(script: './core-commit.sh', returnStdout: true).trim()
/*
Expand Down Expand Up @@ -125,31 +122,34 @@ for (int i = 0; i < splits.size(); i++) {
retryCounts = retryCounts + 1 // increment the retry count before allocating a node in case it fails
node(nodeLabel) {
checkout scm
def image = buildImage ? docker.build('jenkins/ath', '--build-arg uid="$(id -u)" --build-arg gid="$(id -g)" ./src/main/resources/ath-container/') : docker.image('jenkins/ath')
sh 'mkdir -p target/ath-reports && chmod a+rwx target/ath-reports'
def cwd = pwd()
image.inside("-v /var/run/docker.sock:/var/run/docker.sock -v '${cwd}/target/ath-reports:/reports:rw' --shm-size 2g") {
def exclusions = splits.get(index).join('\n')
writeFile file: 'excludes.txt', text: exclusions
infra.withArtifactCachingProxy {
realtimeJUnit(
testResults: 'target/surefire-reports/TEST-*.xml',
testDataPublishers: [[$class: 'AttachmentPublisher']],
// Slow test(s) removal can causes a split to get empty which otherwise fails the build.
// The build failure prevents parallel tests executor to realize the tests are gone so same
// split is run to execute and report zero tests - which fails the build. Permit the test
// results to be empty to break the circle: build after removal executes one empty split
// but not letting the build to fail will cause next build not to try those tests again.
allowEmptyResults: true
) {
sh """
set-java.sh ${jdk}
eval \$(vnc.sh)
java -version
run.sh ${browser} ${jenkinsVersion} -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo -Dmaven.test.failure.ignore=true -DforkCount=1 -B
cp --verbose target/surefire-reports/TEST-*.xml /reports
"""
}
// Need to authenticate on DockerHub with a read-only account to avoid rate limit
infra.withDockerCredentials {
def image = buildImage ? docker.build('jenkins/ath', '--build-arg uid="$(id -u)" --build-arg gid="$(id -g)" ./src/main/resources/ath-container/') : docker.image('jenkins/ath')
sh 'mkdir -p target/ath-reports && chmod a+rwx target/ath-reports'
def cwd = pwd()
image.inside("-v /var/run/docker.sock:/var/run/docker.sock -v '${cwd}/target/ath-reports:/reports:rw' --shm-size 2g") {
def exclusions = splits.get(index).join('\n')
writeFile file: 'excludes.txt', text: exclusions
infra.withArtifactCachingProxy {
realtimeJUnit(
testResults: 'target/surefire-reports/TEST-*.xml',
testDataPublishers: [[$class: 'AttachmentPublisher']],
// Slow test(s) removal can causes a split to get empty which otherwise fails the build.
// The build failure prevents parallel tests executor to realize the tests are gone so same
// split is run to execute and report zero tests - which fails the build. Permit the test
// results to be empty to break the circle: build after removal executes one empty split
// but not letting the build to fail will cause next build not to try those tests again.
allowEmptyResults: true
) {
sh """
set-java.sh ${jdk}
eval \$(vnc.sh)
java -version
run.sh ${browser} ${jenkinsVersion} -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo -Dmaven.test.failure.ignore=true -DforkCount=1 -B
cp --verbose target/surefire-reports/TEST-*.xml /reports
"""
}
}
}
}
withCredentials([string(credentialsId: 'launchable-jenkins-acceptance-test-harness', variable: 'LAUNCHABLE_TOKEN')]) {
Expand Down

0 comments on commit 71de485

Please sign in to comment.