Skip to content

Commit

Permalink
Merge pull request #1626 from dduportal/fix/ubuntu/golang-installation
Browse files Browse the repository at this point in the history
fix(ubuntu) ensure golang installation works with the default `jenkins` user `GOPATH`
  • Loading branch information
dduportal authored Jan 2, 2025
2 parents aa99401 + c68c7f1 commit aa6173e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions provisioning/ubuntu-provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ function install_golang(){
tar --extract --gunzip --directory="/usr/local/"
## 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
## Default GOPATH need to be created
mkdir -p "${userhome}/go"
chown jenkins:jenkins "${userhome}/go"
}

## Ensure GolangCIlint is installed
Expand All @@ -225,6 +228,8 @@ function install_golangcilint(){
## Ensure that the Jenkins Agent commons requirements are installed
function install_JA_requirements(){
apt-get update --quiet
# JQ_VERSION is an env var provided outside of the script
# shellcheck disable=SC2153
apt-get install --yes --no-install-recommends \
make \
unzip \
Expand Down Expand Up @@ -348,6 +353,8 @@ function install_jdks() {
## Prevent Java null pointer exception due to missing fontconfig / add jq that should already be installed but make this install_jdk function idempotent
apt-get install --yes --no-install-recommends fontconfig jq="${JQ_VERSION}*"

# JDK*_VERSION are env. vars provided outside of the script
# shellcheck disable=SC2153
for jdk_version_to_install in "${JDK8_VERSION}" "${JDK11_VERSION}" "${JDK17_VERSION}" "${JDK21_VERSION}"
do
echo "=== Installing Temurin JDK version ${jdk_version_to_install}..."
Expand Down Expand Up @@ -433,7 +440,6 @@ function install_jxreleaseversion() {

## Ensure that azure-cli is installed
function install_azurecli() {
local az_repo
apt-get update --quiet
apt-get install --yes --no-install-recommends \
gpg \
Expand Down Expand Up @@ -668,7 +674,7 @@ function install_yamllint() {
## Ensure that the VM is cleaned up of provision artifacts
function cleanup() {
export HISTSIZE=0
rm -rf /tmp/* /var/log/* ${HOME}/.npm
rm -rf /tmp/* /var/log/* "${HOME}/.npm"
sync
}

Expand Down Expand Up @@ -709,8 +715,8 @@ function main() {
install_gh
install_golang
install_golangcilint # must come after golang
install_ruby ${RUBY_PUPPET_VERSION}
install_ruby ${RUBY_VERSION}
install_ruby "${RUBY_PUPPET_VERSION}"
install_ruby "${RUBY_VERSION}"
install_vagrant
install_xq
install_yq
Expand Down

0 comments on commit aa6173e

Please sign in to comment.