Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick to 7.x: [CI]: retry with sleep (#20065) #20098

Merged
merged 1 commit into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .ci/scripts/report-codecov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -exuo pipefail

CODECOV_URL=https://codecov.io/bash
if [ -e /usr/local/bin/bash_standard_lib.sh ] ; then
# shellcheck disable=SC1091
source /usr/local/bin/bash_standard_lib.sh
(retry 3 curl -sSLo codecov ${CODECOV_URL})
else
curl -sSLo codecov ${CODECOV_URL}
fi

for i in "$@" ; do
FILE="${i}/build/coverage/full.cov"
if [ -f "${FILE}" ]; then
bash codecov -f "${FILE}"
fi
done
37 changes: 11 additions & 26 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,9 @@ def withBeatsEnv(Map args = [:], Closure body) {
if (archive) {
archiveTestOutput(testResults: '**/build/TEST*.xml', artifacts: '**/build/TEST*.out')
}
reportCoverage()
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
sh(label: 'Report to Codecov', script: '.ci/scripts/report-codecov.sh auditbeat filebeat heartbeat journalbeat libbeat metricbeat packetbeat winlogbeat')
}
}
}
}
Expand Down Expand Up @@ -977,12 +979,12 @@ def withBeatsEnvWin(Map args = [:], Closure body) {
def installTools() {
def i = 2 // Number of retries
if(isUnix()) {
retry(i) { sh(label: "Install Go ${GO_VERSION}", script: ".ci/scripts/install-go.sh") }
retry(i) { sh(label: "Install docker-compose ${DOCKER_COMPOSE_VERSION}", script: ".ci/scripts/install-docker-compose.sh") }
retry(i) { sh(label: "Install Terraform ${TERRAFORM_VERSION}", script: ".ci/scripts/install-terraform.sh") }
retry(i) { sh(label: "Install Mage", script: "make mage") }
retryWithSleep(retries: i, seconds: 5, backoff: true){ sh(label: "Install Go ${GO_VERSION}", script: ".ci/scripts/install-go.sh") }
retryWithSleep(retries: i, seconds: 5, backoff: true){ sh(label: "Install docker-compose ${DOCKER_COMPOSE_VERSION}", script: ".ci/scripts/install-docker-compose.sh") }
retryWithSleep(retries: i, seconds: 5, backoff: true){ sh(label: "Install Terraform ${TERRAFORM_VERSION}", script: ".ci/scripts/install-terraform.sh") }
retryWithSleep(retries: i, seconds: 5, backoff: true){ sh(label: "Install Mage", script: "make mage") }
} else {
retry(i) { bat(label: "Install Go/Mage/Python ${GO_VERSION}", script: ".ci/scripts/install-tools.bat") }
retryWithSleep(retries: i, seconds: 5, backoff: true){ bat(label: "Install Go/Mage/Python ${GO_VERSION}", script: ".ci/scripts/install-tools.bat") }
}
}

Expand Down Expand Up @@ -1085,23 +1087,6 @@ def k8sTest(versions){
}
}

def reportCoverage(){
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
retry(2){
sh(label: 'Report to Codecov', script: '''
curl -sSLo codecov https://codecov.io/bash
for i in auditbeat filebeat heartbeat libbeat metricbeat packetbeat winlogbeat journalbeat
do
FILE="${i}/build/coverage/full.cov"
if [ -f "${FILE}" ]; then
bash codecov -f "${FILE}"
fi
done
''')
}
}
}

/**
* isChanged treats the patterns as regular expressions. In order to check if
* any file in a directoy is modified use `^<path to dir>/.*`.
Expand Down Expand Up @@ -1207,7 +1192,7 @@ def startCloudTestEnv(String name, environments = []) {
try {
for (environment in environments) {
if (environment.cond || runAll) {
retry(2) {
retryWithSleep(retries: 2, seconds: 5, backoff: true){
terraformApply(environment.dir)
}
}
Expand All @@ -1229,7 +1214,7 @@ def terraformCleanup(String stashName, String directory) {
withCloudTestEnv() {
withBeatsEnv(archive: false, withModule: false) {
unstash("terraform-${stashName}")
retry(2) {
retryWithSleep(retries: 2, seconds: 5, backoff: true) {
sh(label: "Terraform Cleanup", script: ".ci/scripts/terraform-cleanup.sh ${directory}")
}
}
Expand All @@ -1242,7 +1227,7 @@ def loadConfigEnvVars(){
env.GO_VERSION = readFile(".go-version").trim()

withEnv(["HOME=${env.WORKSPACE}"]) {
retry(2) { sh(label: "Install Go ${env.GO_VERSION}", script: ".ci/scripts/install-go.sh") }
retryWithSleep(retries: 2, seconds: 5, backoff: true){ sh(label: "Install Go ${env.GO_VERSION}", script: ".ci/scripts/install-go.sh") }
}

// Libbeat is the core framework of Beats. It has no additional dependencies
Expand Down