Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6687727
[CI] prepare windows tooling
v1v Nov 18, 2020
afafcfe
Fix script to support installed gvm and on the fly installations
v1v Nov 18, 2020
4b168a7
Install go explicitly to detect if there is any issue
v1v Nov 19, 2020
13ed857
Debug what's installed
v1v Nov 19, 2020
b3e4853
Remove duplicated logic and fallback to choco install if something ba…
v1v Nov 20, 2020
a744625
Fix w7 32 bits gvm installation
v1v Nov 20, 2020
d22aba0
Refresh env variables
v1v Nov 23, 2020
8c370e3
Refactor and add header to the label
v1v Nov 23, 2020
19bee55
Add debug for the gvm
v1v Nov 23, 2020
59905cc
Minor changes with some env variables
v1v Nov 23, 2020
22d6549
Force the GVM installation in the CI workers
v1v Nov 23, 2020
7591ee0
Remove version
v1v Nov 23, 2020
d1cd178
Avoid a failure and keep moving forward
v1v Nov 23, 2020
4d8e52b
Skip go env since it does not go further
v1v Nov 23, 2020
8ad62cb
Revert "Skip go env since it does not go further"
v1v Nov 23, 2020
0ac7e8f
Revert "Avoid a failure and keep moving forward"
v1v Nov 23, 2020
19e7d7c
Use https://github.com/chocolatey/choco/issues/1461
v1v Nov 23, 2020
c104ded
Bump GVM version
v1v Nov 24, 2020
260807d
go with choco is not installed correctly
v1v Nov 24, 2020
0517864
Force USERPROFILE to point to the workspace
v1v Nov 24, 2020
75bf856
Set the variable first to be used later on
v1v Nov 24, 2020
f22fa2d
Set the environment for chocolatey only
v1v Nov 24, 2020
cfa9f18
Adhoc installation of Go
v1v Nov 24, 2020
ec0e35a
Use another installer to validate it works as expected
v1v Nov 24, 2020
72e0a84
Revert "Adhoc installation of Go"
v1v Nov 24, 2020
48dc27c
Fix URL
v1v Nov 25, 2020
6a3ee9f
Use gvm 0.2.4 that contains the fix for the copy in windows
v1v Dec 2, 2020
6724419
Merge remote-tracking branch 'upstream/master' into feature/windows-7…
v1v Dec 2, 2020
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
45 changes: 32 additions & 13 deletions .ci/scripts/install-tools.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,49 @@ IF ERRORLEVEL 1 (
)
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
)

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
) ELSE (
curl -sL -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.2.2/gvm-windows-386.exe
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.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://github.com/andrewkroh/gvm/releases/download/v0.2.4/gvm-windows-386.exe
IF ERRORLEVEL 1 (
REM gvm installation has failed.
exit /b 1
)
dir "%WORKSPACE%\bin" /b
)
FOR /f "tokens=*" %%i IN ('"gvm.exe" use %GO_VERSION% --format=batch') DO %%i

SET GVM_BIN=gvm.exe
WHERE /q %GVM_BIN%
%GVM_BIN% version

REM Install the given 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
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


go env
IF ERRORLEVEL 1 (
REM go is not configured correctly.
exit /b 1
)

go get github.com/magefile/mage
where mage
mage -version
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
Expand All @@ -61,3 +77,6 @@ IF ERRORLEVEL 1 (
)
gcc --version
where gcc

REM Reset the USERPROFILE
SET USERPROFILE=%PREVIOUS_USERPROFILE%
34 changes: 18 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,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()) {
Expand All @@ -325,7 +325,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"
Expand All @@ -341,6 +342,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}",
Expand All @@ -349,22 +351,14 @@ def withBeatsEnv(Map args = [:], Closure body) {
"RACE_DETECTOR=true",
"TEST_COVERAGE=true",
"TEST_TAGS=${env.TEST_TAGS},oracle",
"GOX_FLAGS=${gox_flags}"
"OLD_USERPROFILE=${env.USERPROFILE}",
"USERPROFILE=${userProfile}"
]) {
if(isDockerInstalled()) {
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 {
Expand Down Expand Up @@ -413,11 +407,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") }
}
}

Expand Down