From 42a40eb894776aff078aff8e85c68e1414b667c5 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Fri, 26 Jan 2024 15:33:52 +0100 Subject: [PATCH 1/3] chore(goss): change npm version check and add adsf to path --- goss/goss-common.yaml | 2 +- provisioning/ubuntu-provision.sh | 5 ++++- sources.pkr.hcl | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/goss/goss-common.yaml b/goss/goss-common.yaml index 2413a8424..dc9c2e7f0 100644 --- a/goss/goss-common.yaml +++ b/goss/goss-common.yaml @@ -80,7 +80,7 @@ command: stdout: - 18.18.2 npm: - exec: npm version + exec: npm --version exit-status: 0 packer: exec: packer -v diff --git a/provisioning/ubuntu-provision.sh b/provisioning/ubuntu-provision.sh index 034e25e32..f7c97d4e4 100755 --- a/provisioning/ubuntu-provision.sh +++ b/provisioning/ubuntu-provision.sh @@ -154,6 +154,9 @@ function install_asdf() { echo ". ${asdf_install_dir}/asdf.sh" >> "${profile_script}" chown -R "${username}:${groupname}" "${userhome}" rm -f "${archive}" + + ## append to the system wide path variable, need to be seconded for docker in packer sources.pkr.hcl + sed -e "/^PATH/s/\"$/:\${asdf_install_dir}\/shims:\${asdf_install_dir}\/bin\"/g" -i /etc/environment } ## Install the ASDF Plugin passed as argument ($1 is the name and $2 the URL) @@ -205,7 +208,7 @@ function install_golang(){ golang_download_url="https://go.dev/dl/go${GOLANG_VERSION}.linux-${ARCHITECTURE}.tar.gz" curl --fail --silent --show-error --location "${golang_download_url}" | \ tar --extract --gunzip --directory="/usr/local/" - ## append to the system wide path variable + ## append to the system wide path variable, need to be seconded for docker in packer sources.pkr.hcl sed -e '/^PATH/s/"$/:\/usr\/local\/go\/bin"/g' -i /etc/environment } diff --git a/sources.pkr.hcl b/sources.pkr.hcl index 789ccf35e..c805550c9 100644 --- a/sources.pkr.hcl +++ b/sources.pkr.hcl @@ -55,7 +55,7 @@ source "docker" "base" { "ENV LANGUAGE=${element(split(".", var.locale), 0)}:${element(split("_", var.locale), 0)}", "ENV LC_ALL=${var.locale}", "ENV AGENT_WORKDIR=/home/jenkins/agent", - "ENV PATH=$${PATH}:/usr/local/go/bin", + "ENV PATH=$${PATH}:/usr/local/go/bin:/home/jenkins/.asdf/shims:/home/jenkins/.asdf/bin", "WORKDIR /home/jenkins", "ENTRYPOINT [\"/usr/local/bin/jenkins-agent\"]", "USER jenkins", From f7a374ce84e9746a9c75f7ccbfea5dfae24e9e19 Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 30 Jan 2024 10:38:19 +0100 Subject: [PATCH 2/3] enhance goss test to avoir false negatif --- goss/goss-common.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/goss/goss-common.yaml b/goss/goss-common.yaml index dc9c2e7f0..e1af3185f 100644 --- a/goss/goss-common.yaml +++ b/goss/goss-common.yaml @@ -78,10 +78,14 @@ command: exec: node --version exit-status: 0 stdout: - - 18.18.2 + and: + - 18.18.2 + - not: 'Please install a version by running one of the following' npm: exec: npm --version exit-status: 0 + stdout: + - not: 'No preset version installed for command npm' packer: exec: packer -v exit-status: 0 From 60b3767e74ca4938aab447ce56d177b31a87bfdc Mon Sep 17 00:00:00 2001 From: smerle33 Date: Tue, 30 Jan 2024 12:11:26 +0100 Subject: [PATCH 3/3] comment until bug issue solved in goss --- goss/goss-common.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/goss/goss-common.yaml b/goss/goss-common.yaml index e1af3185f..962d8b999 100644 --- a/goss/goss-common.yaml +++ b/goss/goss-common.yaml @@ -78,14 +78,15 @@ command: exec: node --version exit-status: 0 stdout: - and: - - 18.18.2 - - not: 'Please install a version by running one of the following' + - 18.18.2 + # and: + # - contain: 18.18.2 + # - not: 'Please install a version by running one of the following' npm: exec: npm --version exit-status: 0 - stdout: - - not: 'No preset version installed for command npm' + # stdout: + # - not: 'No preset version installed for command npm' packer: exec: packer -v exit-status: 0