From 668772718bd8ebe3b579cafcaa9f6a6754b9ff0b Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 18 Nov 2020 17:35:11 +0000 Subject: [PATCH 01/27] [CI] prepare windows tooling --- .ci/scripts/install-tools.bat | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index a93bb6750504..7bf4ece7bde6 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -16,21 +16,29 @@ mkdir %WORKSPACE%\bin REM If 32 bits then install the GVM accordingly IF NOT EXIST "%PROGRAMFILES(X86)%" ( - curl -sL -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe ) where /q gvm IF ERRORLEVEL 1 ( IF EXIST "%PROGRAMFILES(X86)%" ( - curl -sL -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-amd64.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-amd64.exe ) ELSE ( - curl -sL -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe ) IF ERRORLEVEL 1 ( exit /b 1 ) dir "%WORKSPACE%\bin" /b ) + +if EXIST %WORKSPACE%\bin\gvm.exe ( + gvm.exe version +) else ( + REM gvm.exe has not been installed for some unknown reasons + exit /b 1 +) + FOR /f "tokens=*" %%i IN ('"gvm.exe" use %GO_VERSION% --format=batch') DO %%i go env From afafcfe7c5063acd73c6faaa7492a9cc1de363bd Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 18 Nov 2020 18:08:11 +0000 Subject: [PATCH 02/27] Fix script to support installed gvm and on the fly installations --- .ci/scripts/install-tools.bat | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 7bf4ece7bde6..cfc9f94c7641 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -19,27 +19,27 @@ IF NOT EXIST "%PROGRAMFILES(X86)%" ( curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe ) -where /q gvm +set GVM_BIN=gvm +where /q %GVM_BIN% IF ERRORLEVEL 1 ( + set GVM_BIN=gvm.exe IF EXIST "%PROGRAMFILES(X86)%" ( - curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-amd64.exe + curl -L -o %WORKSPACE%\bin\%GVM_BIN% https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-amd64.exe ) ELSE ( - curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe + curl -L -o %WORKSPACE%\bin\%GVM_BIN% https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe ) IF ERRORLEVEL 1 ( exit /b 1 ) - dir "%WORKSPACE%\bin" /b -) - -if EXIST %WORKSPACE%\bin\gvm.exe ( - gvm.exe version -) else ( - REM gvm.exe has not been installed for some unknown reasons - exit /b 1 + if EXIST %WORKSPACE%\bin\%GVM_BIN% ( + %GVM_BIN% version + ) else ( + REM gvm.exe has not been installed for some unknown reasons + exit /b 1 + ) ) -FOR /f "tokens=*" %%i IN ('"gvm.exe" use %GO_VERSION% --format=batch') DO %%i +FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i go env go get github.com/magefile/mage From 4b168a7dd8ddaddaa77b571e70d9f9cc6457eea2 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 19 Nov 2020 11:10:02 +0000 Subject: [PATCH 03/27] Install go explicitly to detect if there is any issue --- .ci/scripts/install-tools.bat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index cfc9f94c7641..b98d57a11c9d 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -39,6 +39,10 @@ IF ERRORLEVEL 1 ( ) ) +REM Install the given go version +%GVM_BIN% install %GO_VERSION% + +REM Configure the given go version FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i go env From 13ed857537055dc1abda1a79d61a163b26aa7e4f Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 19 Nov 2020 14:46:24 +0000 Subject: [PATCH 04/27] Debug what's installed --- .ci/scripts/install-tools.bat | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index b98d57a11c9d..b2c493086582 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -45,6 +45,9 @@ REM Install the given go version REM Configure the given go version FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i +REM List the gvm installation for debugging purposes +DIR /A /S %GOROOT% + go env go get github.com/magefile/mage where mage From b3e48536bec43b4a1436fe455b66000728c841e2 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 20 Nov 2020 15:32:02 +0000 Subject: [PATCH 05/27] Remove duplicated logic and fallback to choco install if something bad happened with the go installation by the gvm --- .ci/scripts/install-tools.bat | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index b2c493086582..d8214fccf7b7 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -14,21 +14,19 @@ IF ERRORLEVEL 1 ( ) mkdir %WORKSPACE%\bin -REM If 32 bits then install the GVM accordingly -IF NOT EXIST "%PROGRAMFILES(X86)%" ( - curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe +IF EXIST "%PROGRAMFILES(X86)%" ( + SET GVM_FILE=gvm-windows-amd64.exe +) ELSE ( + SET GVM_FILE=gvm-windows-386.exe ) set GVM_BIN=gvm where /q %GVM_BIN% IF ERRORLEVEL 1 ( set GVM_BIN=gvm.exe - IF EXIST "%PROGRAMFILES(X86)%" ( - curl -L -o %WORKSPACE%\bin\%GVM_BIN% https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-amd64.exe - ) ELSE ( - curl -L -o %WORKSPACE%\bin\%GVM_BIN% https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe - ) + curl -L -o %WORKSPACE%\bin\%GVM_BIN% https://github.com/andrewkroh/gvm/releases/download/v0.2.2/%GVM_FILE% IF ERRORLEVEL 1 ( + REM The download of gvm has failed. exit /b 1 ) if EXIST %WORKSPACE%\bin\%GVM_BIN% ( @@ -45,10 +43,16 @@ REM Install the given go version REM Configure the given go version FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i -REM List the gvm installation for debugging purposes -DIR /A /S %GOROOT% - go env +IF ERRORLEVEL 1 ( + REM Fallback the go installation with choco, since gvm in some workers doesn't install go correctly + choco install golang -y -r --no-progress --version=%GO_VERSION% + IF NOT ERRORLEVEL 0 ( + exit /b 1 + ) + go env +) + go get github.com/magefile/mage where mage mage -version From a744625850f02825752c5e1e75009d950cab1129 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 20 Nov 2020 16:46:29 +0000 Subject: [PATCH 06/27] Fix w7 32 bits gvm installation --- .ci/scripts/install-tools.bat | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index d8214fccf7b7..f75e4f8a2fb0 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -14,17 +14,21 @@ IF ERRORLEVEL 1 ( ) mkdir %WORKSPACE%\bin +set GVM_BIN=gvm +SET GVM_URL=https://github.com/andrewkroh/gvm/releases/download/v0.2.2 IF EXIST "%PROGRAMFILES(X86)%" ( SET GVM_FILE=gvm-windows-amd64.exe ) ELSE ( + REM Windows 7 workers got a broken gvm installation. SET GVM_FILE=gvm-windows-386.exe + set GVM_BIN=gvm.exe + curl -L -o %WORKSPACE%\bin\%GVM_BIN% %GVM_URL%/%GVM_FILE% ) -set GVM_BIN=gvm where /q %GVM_BIN% IF ERRORLEVEL 1 ( set GVM_BIN=gvm.exe - curl -L -o %WORKSPACE%\bin\%GVM_BIN% https://github.com/andrewkroh/gvm/releases/download/v0.2.2/%GVM_FILE% + curl -L -o %WORKSPACE%\bin\%GVM_BIN% %GVM_URL%/%GVM_FILE% IF ERRORLEVEL 1 ( REM The download of gvm has failed. exit /b 1 From d22aba038f5ecaa45bc4465733a992fd8259ff06 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 09:29:53 +0000 Subject: [PATCH 07/27] Refresh env variables --- .ci/scripts/install-tools.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index f75e4f8a2fb0..30d304c5e2ab 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -54,6 +54,7 @@ IF ERRORLEVEL 1 ( IF NOT ERRORLEVEL 0 ( exit /b 1 ) + refreshenv go env ) From 8c370e33b5e8c8d8759786533a201dcd1fd4abe9 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 09:33:57 +0000 Subject: [PATCH 08/27] Refactor and add header to the label --- Jenkinsfile | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8236ef55cf0d..3a178a52dd70 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -345,16 +345,7 @@ def withBeatsEnv(Map args = [:], Closure body) { dockerLogin(secret: "${DOCKERELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") } dir("${env.BASE_DIR}") { - installTools() - if(isUnix()) { - // TODO (2020-04-07): This is a work-around to fix the Beat generator tests. - // See https://github.com/elastic/beats/issues/17787. - sh(label: 'check git config', script: ''' - if [ -z "$(git config --get user.email)" ]; then - git config --global user.email "beatsmachine@users.noreply.github.com" - git config --global user.name "beatsmachine" - fi''') - } + installTools(args) // Skip to upload the generated files by default. def upload = false try { @@ -403,11 +394,19 @@ def fixPermissions(location) { * This method installs the required dependencies that are for some reason not available in the * CI Workers. */ -def installTools() { +def installTools(args) { + def stepHeader = "${args.id?.trim() ? args.id : env.STAGE_NAME}" if(isUnix()) { - retryWithSleep(retries: 2, seconds: 5, backoff: true){ sh(label: "Install Go/Mage/Python/Docker/Terraform ${GO_VERSION}", script: '.ci/scripts/install-tools.sh') } + retryWithSleep(retries: 2, seconds: 5, backoff: true){ sh(label: "${stepHeader} - Install Go/Mage/Python/Docker/Terraform ${GO_VERSION}", script: '.ci/scripts/install-tools.sh') } + // TODO (2020-04-07): This is a work-around to fix the Beat generator tests. + // See https://github.com/elastic/beats/issues/17787. + sh(label: 'check git config', script: ''' + if [ -z "$(git config --get user.email)" ]; then + git config --global user.email "beatsmachine@users.noreply.github.com" + git config --global user.name "beatsmachine" + fi''') } else { - retryWithSleep(retries: 2, seconds: 5, backoff: true){ bat(label: "Install Go/Mage/Python ${GO_VERSION}", script: ".ci/scripts/install-tools.bat") } + retryWithSleep(retries: 2, seconds: 5, backoff: true){ bat(label: "${stepHeader} - Install Go/Mage/Python ${GO_VERSION}", script: ".ci/scripts/install-tools.bat") } } } From 19bee557f1da12a1423dae9c56746699f7a3b85c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 10:38:09 +0000 Subject: [PATCH 09/27] Add debug for the gvm --- .ci/scripts/install-tools.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 30d304c5e2ab..9c153b15b53a 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -42,7 +42,7 @@ IF ERRORLEVEL 1 ( ) REM Install the given go version -%GVM_BIN% install %GO_VERSION% +%GVM_BIN% --debug install %GO_VERSION% REM Configure the given go version FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i From 59905ccb518fc47d1a0077c9dd7498cc62a5390d Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 13:34:53 +0000 Subject: [PATCH 10/27] Minor changes with some env variables --- .ci/scripts/install-tools.bat | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 9c153b15b53a..1c4425f6fcbe 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -14,21 +14,21 @@ IF ERRORLEVEL 1 ( ) mkdir %WORKSPACE%\bin -set GVM_BIN=gvm -SET GVM_URL=https://github.com/andrewkroh/gvm/releases/download/v0.2.2 +SET GVM_BIN=gvm +SET GVM_VERSION=v0.2.2 IF EXIST "%PROGRAMFILES(X86)%" ( - SET GVM_FILE=gvm-windows-amd64.exe + SET GVM_URL=https://github.com/andrewkroh/gvm/releases/download/%GVM_VERSION%/gvm-windows-amd64.exe ) ELSE ( REM Windows 7 workers got a broken gvm installation. - SET GVM_FILE=gvm-windows-386.exe - set GVM_BIN=gvm.exe - curl -L -o %WORKSPACE%\bin\%GVM_BIN% %GVM_URL%/%GVM_FILE% + SET GVM_BIN=gvm.exe + SET GVM_URL=https://github.com/andrewkroh/gvm/releases/download/%GVM_VERSION%/gvm-windows-386.exe + curl -L -o %WORKSPACE%\bin\gvm.exe %GVM_URL% ) where /q %GVM_BIN% IF ERRORLEVEL 1 ( - set GVM_BIN=gvm.exe - curl -L -o %WORKSPACE%\bin\%GVM_BIN% %GVM_URL%/%GVM_FILE% + SET GVM_BIN=gvm.exe + curl -L -o %WORKSPACE%\bin\%GVM_BIN% %GVM_URL% IF ERRORLEVEL 1 ( REM The download of gvm has failed. exit /b 1 From 22d65497e2bb3a892d4dbdf1edc2feaa99f23b21 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 14:13:47 +0000 Subject: [PATCH 11/27] Force the GVM installation in the CI workers --- .ci/scripts/install-tools.bat | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 1c4425f6fcbe..edc0a83ea59f 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -17,30 +17,25 @@ mkdir %WORKSPACE%\bin SET GVM_BIN=gvm SET GVM_VERSION=v0.2.2 IF EXIST "%PROGRAMFILES(X86)%" ( - SET GVM_URL=https://github.com/andrewkroh/gvm/releases/download/%GVM_VERSION%/gvm-windows-amd64.exe + REM Force the gvm installation. + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-amd64.exe + IF ERRORLEVEL 1 ( + REM gvm installation has failed. + exit /b 1 + ) ) ELSE ( REM Windows 7 workers got a broken gvm installation. SET GVM_BIN=gvm.exe - SET GVM_URL=https://github.com/andrewkroh/gvm/releases/download/%GVM_VERSION%/gvm-windows-386.exe - curl -L -o %WORKSPACE%\bin\gvm.exe %GVM_URL% -) - -where /q %GVM_BIN% -IF ERRORLEVEL 1 ( - SET GVM_BIN=gvm.exe - curl -L -o %WORKSPACE%\bin\%GVM_BIN% %GVM_URL% + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe IF ERRORLEVEL 1 ( - REM The download of gvm has failed. - exit /b 1 - ) - if EXIST %WORKSPACE%\bin\%GVM_BIN% ( - %GVM_BIN% version - ) else ( - REM gvm.exe has not been installed for some unknown reasons + REM gvm installation has failed. exit /b 1 ) ) +where /q %GVM_BIN% +%GVM_BIN% version + REM Install the given go version %GVM_BIN% --debug install %GO_VERSION% From 7591ee0a929d954b24a2a506c0bf44e1272e3cc8 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 14:20:32 +0000 Subject: [PATCH 12/27] Remove version --- .ci/scripts/install-tools.bat | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index edc0a83ea59f..3b3fae1a1cda 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -14,10 +14,9 @@ IF ERRORLEVEL 1 ( ) mkdir %WORKSPACE%\bin -SET GVM_BIN=gvm -SET GVM_VERSION=v0.2.2 IF EXIST "%PROGRAMFILES(X86)%" ( REM Force the gvm installation. + SET GVM_BIN=gvm.exe curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-amd64.exe IF ERRORLEVEL 1 ( REM gvm installation has failed. @@ -25,7 +24,6 @@ IF EXIST "%PROGRAMFILES(X86)%" ( ) ) ELSE ( REM Windows 7 workers got a broken gvm installation. - SET GVM_BIN=gvm.exe curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe IF ERRORLEVEL 1 ( REM gvm installation has failed. @@ -33,7 +31,8 @@ IF EXIST "%PROGRAMFILES(X86)%" ( ) ) -where /q %GVM_BIN% +SET GVM_BIN=gvm.exe +WHERE /q %GVM_BIN% %GVM_BIN% version REM Install the given go version From d1cd178d2c24c998345c405d1f67ea2f788c652f Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 16:30:46 +0000 Subject: [PATCH 13/27] Avoid a failure and keep moving forward --- .ci/scripts/install-tools.bat | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 3b3fae1a1cda..a73f0c5f1b79 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -48,8 +48,9 @@ IF ERRORLEVEL 1 ( IF NOT ERRORLEVEL 0 ( exit /b 1 ) - refreshenv - go env + REM Even if it failed let's move forward + refreshenv || echo "WARNING - refreshing env variables failed" + go env || echo "WARNING - go env failed" ) go get github.com/magefile/mage From 4d8e52b68f466ff8ad046b12fb63f52857b55872 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 17:05:35 +0000 Subject: [PATCH 14/27] Skip go env since it does not go further --- .ci/scripts/install-tools.bat | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index a73f0c5f1b79..2d567cef96ea 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -48,9 +48,7 @@ IF ERRORLEVEL 1 ( IF NOT ERRORLEVEL 0 ( exit /b 1 ) - REM Even if it failed let's move forward - refreshenv || echo "WARNING - refreshing env variables failed" - go env || echo "WARNING - go env failed" + refreshenv ) go get github.com/magefile/mage From 8ad62cb970647359acee38b6bc3ad4022e16b074 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 17:44:46 +0000 Subject: [PATCH 15/27] Revert "Skip go env since it does not go further" This reverts commit 4d8e52b68f466ff8ad046b12fb63f52857b55872. --- .ci/scripts/install-tools.bat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 2d567cef96ea..a73f0c5f1b79 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -48,7 +48,9 @@ IF ERRORLEVEL 1 ( IF NOT ERRORLEVEL 0 ( exit /b 1 ) - refreshenv + REM Even if it failed let's move forward + refreshenv || echo "WARNING - refreshing env variables failed" + go env || echo "WARNING - go env failed" ) go get github.com/magefile/mage From 0ac7e8f1ccdd62a98e4eb7729e975bea699ae1cb Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 17:45:05 +0000 Subject: [PATCH 16/27] Revert "Avoid a failure and keep moving forward" This reverts commit d1cd178d2c24c998345c405d1f67ea2f788c652f. --- .ci/scripts/install-tools.bat | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index a73f0c5f1b79..3b3fae1a1cda 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -48,9 +48,8 @@ IF ERRORLEVEL 1 ( IF NOT ERRORLEVEL 0 ( exit /b 1 ) - REM Even if it failed let's move forward - refreshenv || echo "WARNING - refreshing env variables failed" - go env || echo "WARNING - go env failed" + refreshenv + go env ) go get github.com/magefile/mage From 19e7d7c7770f4d374c8f5572605a5c90a59b29d5 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 23 Nov 2020 17:46:19 +0000 Subject: [PATCH 17/27] Use https://github.com/chocolatey/choco/issues/1461 --- .ci/scripts/install-tools.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 3b3fae1a1cda..5fbdc1f4d87a 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -48,7 +48,8 @@ IF ERRORLEVEL 1 ( IF NOT ERRORLEVEL 0 ( exit /b 1 ) - refreshenv + REM use choco refresh approach (see https://github.com/chocolatey/choco/issues/1461) + call RefreshEnv.cmd go env ) From c104ded397536e16bccabfab487a826bce4c5261 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 24 Nov 2020 08:33:08 +0000 Subject: [PATCH 18/27] Bump GVM version --- .ci/scripts/install-tools.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 5fbdc1f4d87a..9aaeb6e304fa 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -17,14 +17,14 @@ mkdir %WORKSPACE%\bin IF EXIST "%PROGRAMFILES(X86)%" ( REM Force the gvm installation. SET GVM_BIN=gvm.exe - curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-amd64.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.3/gvm-windows-amd64.exe IF ERRORLEVEL 1 ( REM gvm installation has failed. exit /b 1 ) ) ELSE ( REM Windows 7 workers got a broken gvm installation. - curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.3/gvm-windows-386.exe IF ERRORLEVEL 1 ( REM gvm installation has failed. exit /b 1 From 260807d54f1c71957822119af919a6f417cb747d Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 24 Nov 2020 08:33:37 +0000 Subject: [PATCH 19/27] go with choco is not installed correctly --- .ci/scripts/install-tools.bat | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 9aaeb6e304fa..70644648f1c2 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -43,14 +43,8 @@ FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i go env IF ERRORLEVEL 1 ( - REM Fallback the go installation with choco, since gvm in some workers doesn't install go correctly - choco install golang -y -r --no-progress --version=%GO_VERSION% - IF NOT ERRORLEVEL 0 ( - exit /b 1 - ) - REM use choco refresh approach (see https://github.com/chocolatey/choco/issues/1461) - call RefreshEnv.cmd - go env + REM go is not configured correctly. + exit /b 1 ) go get github.com/magefile/mage From 05178644186448418ff3c3f9f62fffdb3c264b02 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 24 Nov 2020 14:46:30 +0000 Subject: [PATCH 20/27] Force USERPROFILE to point to the workspace --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3a178a52dd70..913fead88e82 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -331,6 +331,7 @@ def withBeatsEnv(Map args = [:], Closure body) { "DOCKER_PULL=0", "GOPATH=${env.WORKSPACE}", "GOROOT=${goRoot}", + "GOX_FLAGS=${gox_flags}", "HOME=${env.WORKSPACE}", "MAGEFILE_CACHE=${magefile}", "MODULE=${module}", @@ -339,7 +340,7 @@ def withBeatsEnv(Map args = [:], Closure body) { "RACE_DETECTOR=true", "TEST_COVERAGE=true", "TEST_TAGS=${env.TEST_TAGS},oracle", - "GOX_FLAGS=${gox_flags}" + "USERPROFILE=${env.WORKSPACE}" ]) { if(isDockerInstalled()) { dockerLogin(secret: "${DOCKERELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") From 75bf85673ba593ff1b8112b7bcf35ef2b9169005 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 24 Nov 2020 14:48:38 +0000 Subject: [PATCH 21/27] Set the variable first to be used later on --- Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 913fead88e82..b598db6fa6b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -293,7 +293,7 @@ def withBeatsEnv(Map args = [:], Closure body) { def withModule = args.get('withModule', false) def directory = args.get('directory', '') - def goRoot, path, magefile, pythonEnv, testResults, artifacts, gox_flags + def goRoot, path, magefile, pythonEnv, testResults, artifacts, gox_flags, userProfile if(isUnix()) { if (isArm() && is64arm()) { @@ -315,7 +315,8 @@ def withBeatsEnv(Map args = [:], Closure body) { def goArch = is32() ? '386' : 'amd64' def chocoPath = 'C:\\ProgramData\\chocolatey\\bin' def chocoPython3Path = 'C:\\Python38;C:\\Python38\\Scripts' - goRoot = "${env.USERPROFILE}\\.gvm\\versions\\go${GO_VERSION}.windows.${goArch}" + userProfile="${env.WORKSPACE}" + goRoot = "${userProfile}\\.gvm\\versions\\go${GO_VERSION}.windows.${goArch}" path = "${env.WORKSPACE}\\bin;${goRoot}\\bin;${chocoPath};${chocoPython3Path};C:\\tools\\mingw${mingwArch}\\bin;${env.PATH}" magefile = "${env.WORKSPACE}\\.magefile" testResults = "**\\build\\TEST*.xml" @@ -340,7 +341,7 @@ def withBeatsEnv(Map args = [:], Closure body) { "RACE_DETECTOR=true", "TEST_COVERAGE=true", "TEST_TAGS=${env.TEST_TAGS},oracle", - "USERPROFILE=${env.WORKSPACE}" + "USERPROFILE=${userProfile}" ]) { if(isDockerInstalled()) { dockerLogin(secret: "${DOCKERELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") From f22fa2de1f5b23ce562b8869103f5da1507f66d6 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 24 Nov 2020 16:23:35 +0000 Subject: [PATCH 22/27] Set the environment for chocolatey only --- .ci/scripts/install-tools.bat | 6 ++++++ Jenkinsfile | 1 + 2 files changed, 7 insertions(+) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 70644648f1c2..45baf9964794 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -54,6 +54,9 @@ IF ERRORLEVEL 1 ( exit /b 1 ) +REM Set the USERPROFILE to the previous location to fix issues with chocolatey in windows 2019 +SET PREVIOUS_USERPROFILE=%USERPROFILE% +SET USERPROFILE=%OLD_USERPROFILE% IF NOT EXIST C:\Python38\python.exe ( REM Install python 3.8 choco install python -y -r --no-progress --version 3.8.5 @@ -74,3 +77,6 @@ IF ERRORLEVEL 1 ( ) gcc --version where gcc + +REM Reset the USERPROFILE +SET USERPROFILE=%PREVIOUS_USERPROFILE% \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index b598db6fa6b5..e22f0f975d08 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -341,6 +341,7 @@ def withBeatsEnv(Map args = [:], Closure body) { "RACE_DETECTOR=true", "TEST_COVERAGE=true", "TEST_TAGS=${env.TEST_TAGS},oracle", + "OLD_USERPROFILE=${env.USERPROFILE}", "USERPROFILE=${userProfile}" ]) { if(isDockerInstalled()) { From cfa9f1845997f4c420d8fe0a93208abbb4e68ec8 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 24 Nov 2020 18:00:45 +0000 Subject: [PATCH 23/27] Adhoc installation of Go --- .ci/scripts/install-tools.bat | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 45baf9964794..238dfb63f678 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -43,8 +43,23 @@ FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i go env IF ERRORLEVEL 1 ( - REM go is not configured correctly. - exit /b 1 + REM go is not configured correctly let's fallback with some scripting + where /q unzip + IF ERRORLEVEL 1 ( + choco install unzip -y --no-progress --skipdownloadcache + ) + IF EXIST "%PROGRAMFILES(X86)%" ( + curl -L -o %USERPROFILE%\.gvm\go.zip https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.zip + unzip -q -u -o %USERPROFILE%\.gvm\go.zip -d %USERPROFILE%\.gvm\.go + MOVE %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.amd64 %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.amd64.old + MOVE /Y .go\go %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.amd64 + ) ELSE ( + curl -L -o %USERPROFILE%\.gvm\go.zip https://storage.googleapis.com/golang/go%GO_VERSION%.windows-386.zip + unzip -q -u -o %USERPROFILE%\.gvm\go.zip -d %USERPROFILE%\.gvm\.go + MOVE %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.386 %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.386.old + MOVE /Y .go\go %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.386 + ) + go env ) go get github.com/magefile/mage From ec0e35a085d89184db28d6ccd090198204603624 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 24 Nov 2020 19:04:39 +0000 Subject: [PATCH 24/27] Use another installer to validate it works as expected --- .ci/scripts/install-tools.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 238dfb63f678..a6f883a6b10f 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -17,7 +17,7 @@ mkdir %WORKSPACE%\bin IF EXIST "%PROGRAMFILES(X86)%" ( REM Force the gvm installation. SET GVM_BIN=gvm.exe - curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.3/gvm-windows-amd64.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://s3.us-east-1.amazonaws.com/deploy.andrewkroh.com/gvm/gvm-windows-amd64.exe IF ERRORLEVEL 1 ( REM gvm installation has failed. exit /b 1 From 72e0a84ffa5180b67198493499b80c6cb549a369 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 24 Nov 2020 19:31:46 +0000 Subject: [PATCH 25/27] Revert "Adhoc installation of Go" This reverts commit cfa9f1845997f4c420d8fe0a93208abbb4e68ec8. --- .ci/scripts/install-tools.bat | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index a6f883a6b10f..99b37b842862 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -43,23 +43,8 @@ FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i go env IF ERRORLEVEL 1 ( - REM go is not configured correctly let's fallback with some scripting - where /q unzip - IF ERRORLEVEL 1 ( - choco install unzip -y --no-progress --skipdownloadcache - ) - IF EXIST "%PROGRAMFILES(X86)%" ( - curl -L -o %USERPROFILE%\.gvm\go.zip https://storage.googleapis.com/golang/go%GO_VERSION%.windows-amd64.zip - unzip -q -u -o %USERPROFILE%\.gvm\go.zip -d %USERPROFILE%\.gvm\.go - MOVE %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.amd64 %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.amd64.old - MOVE /Y .go\go %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.amd64 - ) ELSE ( - curl -L -o %USERPROFILE%\.gvm\go.zip https://storage.googleapis.com/golang/go%GO_VERSION%.windows-386.zip - unzip -q -u -o %USERPROFILE%\.gvm\go.zip -d %USERPROFILE%\.gvm\.go - MOVE %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.386 %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.386.old - MOVE /Y .go\go %USERPROFILE%\.gvm\versions\go%GO_VERSION%.windows.386 - ) - go env + REM go is not configured correctly. + exit /b 1 ) go get github.com/magefile/mage From 48dc27c81c7f57035d09e9db1e63198c219c4321 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 25 Nov 2020 14:16:30 +0000 Subject: [PATCH 26/27] Fix URL --- .ci/scripts/install-tools.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 99b37b842862..7e7ae40d7753 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -24,7 +24,7 @@ IF EXIST "%PROGRAMFILES(X86)%" ( ) ) ELSE ( REM Windows 7 workers got a broken gvm installation. - curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.3/gvm-windows-386.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://s3.us-east-1.amazonaws.com/deploy.andrewkroh.com/gvm/gvm-windows-386.exe IF ERRORLEVEL 1 ( REM gvm installation has failed. exit /b 1 From 6a3ee9f64ad2550b2ce05dad7d9b27a1537e1964 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Wed, 2 Dec 2020 09:32:41 +0000 Subject: [PATCH 27/27] Use gvm 0.2.4 that contains the fix for the copy in windows --- .ci/scripts/install-tools.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/install-tools.bat b/.ci/scripts/install-tools.bat index 7e7ae40d7753..839cb745fbac 100644 --- a/.ci/scripts/install-tools.bat +++ b/.ci/scripts/install-tools.bat @@ -17,14 +17,14 @@ mkdir %WORKSPACE%\bin IF EXIST "%PROGRAMFILES(X86)%" ( REM Force the gvm installation. SET GVM_BIN=gvm.exe - curl -L -o %WORKSPACE%\bin\gvm.exe https://s3.us-east-1.amazonaws.com/deploy.andrewkroh.com/gvm/gvm-windows-amd64.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.4/gvm-windows-amd64.exe IF ERRORLEVEL 1 ( REM gvm installation has failed. exit /b 1 ) ) ELSE ( REM Windows 7 workers got a broken gvm installation. - curl -L -o %WORKSPACE%\bin\gvm.exe https://s3.us-east-1.amazonaws.com/deploy.andrewkroh.com/gvm/gvm-windows-386.exe + curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.4/gvm-windows-386.exe IF ERRORLEVEL 1 ( REM gvm installation has failed. exit /b 1