Skip to content

Commit

Permalink
chore(updatecli/goss): change yaml engine to comply with goss templat…
Browse files Browse the repository at this point in the history
…ing on goss-windows and improve goss test (#1170)

* chore(goss): add environement variable to goss execution

* change yaml engine to comply with goss templating

* correct casse for updatecli old behavior

* quotes windows command for space escaping

* scalar block for command to avoid quotes

* split powershell command to catch error code

* escaping

* less timeout for goss on windows and try simple quotes for escaping exec

* escaping command goss

* debug if path exist

* DEBUG

* debug

* debug

* change to windows parameters kind

* change to windows parameters kind

* correct exec with () to ensure correct interpolation, tested locally

* Apply suggestions from code review

Co-authored-by: Damien Duportal <damien.duportal@gmail.com>

---------

Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
  • Loading branch information
smerle33 and dduportal authored May 23, 2024
1 parent 0608766 commit 24740d1
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 7 deletions.
16 changes: 14 additions & 2 deletions build-jenkins-agent-windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,20 @@ build {
inline = [
"$ErrorActionPreference = 'Stop'",
"goss --version",
"goss --use-alpha=1 --gossfile C:/goss-windows.yaml --loglevel DEBUG validate --retry-timeout 300s",
"goss --use-alpha=1 --gossfile C:/goss-common.yaml --loglevel DEBUG validate --retry-timeout 300s",
"goss --use-alpha=1 --gossfile C:/goss-windows.yaml --loglevel DEBUG validate --retry-timeout 60s",
]
}

provisioner "powershell" {
environment_vars = local.provisioning_env_vars
inline = [
"goss --use-alpha=1 --gossfile C:/goss-common.yaml --loglevel DEBUG validate --retry-timeout 60s",
]
}

provisioner "powershell" {
environment_vars = local.provisioning_env_vars
inline = [
"Remove-Item -Force C:/goss-windows.yaml",
"Remove-Item -Force C:/goss-common.yaml",
"Remove-Item -Force C:/visualstudio.vsconfig",
Expand Down
5 changes: 2 additions & 3 deletions goss/goss-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ command:
stdout:
- 2.4.1
visualstudio:
exec: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe -nologo -version
exec: ("C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" "/nologo" "/version")
exit-status: 0
stdout:
- /16\.\d+\.\d+\.\d+/
skip: |
{{ not (eq .Env.AGENT_OS_VERSION "2019") }}
skip: {{ not (eq .Env.AGENT_OS_VERSION "2019") }}
file:
C:\Program Files\Chromium\Application\:
contains: []
Expand Down
1 change: 1 addition & 0 deletions updatecli/updatecli.d/jdk11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ targets:
name: Update the JDK11 version in the goss test
kind: yaml
spec:
engine: "yamlpath"
files:
- goss/goss-linux.yaml
- goss/goss-windows.yaml
Expand Down
1 change: 1 addition & 0 deletions updatecli/updatecli.d/jdk17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ targets:
name: Update the JDK17 version in the goss test
kind: yaml
spec:
engine: "yamlpath"
files:
- goss/goss-linux.yaml
- goss/goss-windows.yaml
Expand Down
1 change: 1 addition & 0 deletions updatecli/updatecli.d/jdk21.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ targets:
name: Update the JDK21 version in the goss test
kind: yaml
spec:
engine: "yamlpath"
files:
- goss/goss-linux.yaml
- goss/goss-windows.yaml
Expand Down
1 change: 1 addition & 0 deletions updatecli/updatecli.d/jdk8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ targets:
captureindex: 1
- addprefix: '1.8.0_'
spec:
engine: "yamlpath"
files:
- goss/goss-linux.yaml
- goss/goss-windows.yaml
Expand Down
1 change: 1 addition & 0 deletions updatecli/updatecli.d/nodejs-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ targets:
sourceid: lastReleaseVersion
kind: yaml
spec:
engine: "yamlpath"
files:
- goss/goss-windows.yaml
key: $.command.nodejs.stdout[0]
Expand Down
3 changes: 2 additions & 1 deletion updatecli/updatecli.d/pwsh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ targets:
kind: yaml
spec:
file: "provisioning/tools-versions.yml"
key: "windows_pwsh_version"
key: $.windows_pwsh_version
scmid: default
updatePwshVersionInGoss:
name: Update the `Pwsh` version in the goss test
kind: yaml
spec:
engine: "yamlpath"
files:
- "goss/goss-windows.yaml"
key: $.command.pwsh.stdout[0]
Expand Down
1 change: 1 addition & 0 deletions updatecli/updatecli.d/python3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ targets:
name: Update the `python3` version in the goss test
kind: yaml
spec:
engine: "yamlpath"
files:
- "goss/goss-windows.yaml" #fixed only on windows
key: $.command.python3.stdout[0]
Expand Down
3 changes: 2 additions & 1 deletion updatecli/updatecli.d/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sources:
name: "Get the latest Ruby version"
spec:
image: "ruby"
tagFilter: >-
tagfilter: >-
\d\.\d\.\d$
versionfilter:
kind: regex
Expand Down Expand Up @@ -58,6 +58,7 @@ targets:
sourceid: rubyDockerImageLatestVersion
kind: yaml
spec:
engine: "yamlpath"
files:
- goss/goss-windows.yaml
key: $.command.ruby.stdout[0]
Expand Down
1 change: 1 addition & 0 deletions updatecli/updatecli.d/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ targets:
name: "Update the `vagrant` version in the goss test"
kind: yaml
spec:
engine: "yamlpath"
files:
- goss/goss-windows.yaml # windows only as the linux arm64 vagrant version is not pinned
key: $.command.vagrant.stdout[0]
Expand Down

0 comments on commit 24740d1

Please sign in to comment.