diff --git a/images/linux/scripts/installers/hosted-tool-cache.sh b/images/linux/scripts/installers/hosted-tool-cache.sh index 66ab532e..f9e5b918 100644 --- a/images/linux/scripts/installers/hosted-tool-cache.sh +++ b/images/linux/scripts/installers/hosted-tool-cache.sh @@ -10,12 +10,23 @@ source $HELPER_SCRIPTS/document.sh # Fail out if any setups fail set -e +TOOLCACHE_REGISTRY="npm.pkg.github.com" + AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache mkdir $AGENT_TOOLSDIRECTORY echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment - chmod -R 777 $AGENT_TOOLSDIRECTORY +echo "Configure npm to use github package registry for '@actions' scope" +npm config set @actions:registry "https://${TOOLCACHE_REGISTRY}" + +# Execute in /imagegeneration/installers folder to avoid node_modules creation in $HOME +pushd $INSTALLER_SCRIPT_FOLDER + +# GitHub Package Registry doesn't support downloading public packages without auth so we have to authorize +echo "Configure auth for github package registry" +echo "//${TOOLCACHE_REGISTRY}/:_authToken=${GITHUB_FEED_TOKEN}" > ".npmrc" + echo "Installing npm-toolcache..." TOOLSET_PATH="$INSTALLER_SCRIPT_FOLDER/toolcache.json" @@ -25,10 +36,19 @@ for PACKAGE_NAME in ${PACKAGE_LIST[@]}; do PACKAGE_VERSIONS=($(jq -r ".[\"$PACKAGE_NAME\"] | .[]" $TOOLSET_PATH)) for PACKAGE_VERSION in ${PACKAGE_VERSIONS[@]}; do echo "Install ${PACKAGE_NAME}@${PACKAGE_VERSION}" - npm install ${PACKAGE_NAME}@${PACKAGE_VERSION} --registry=${TOOLCACHE_REGISTRY} + npm install ${PACKAGE_NAME}@${PACKAGE_VERSION} + + exit_code=$? + if [ $exit_code -ne 0 ]; then + echo "${PACKAGE_NAME}@${PACKAGE_VERSION} installation failure; Error:${exit_code}" + + exit 1 + fi done; done; +popd + DocumentInstalledItem "Python:" pythons=$(ls $AGENT_TOOLSDIRECTORY/Python) for python in $pythons; do @@ -45,4 +65,4 @@ DocumentInstalledItem "PyPy:" pypys=$(ls $AGENT_TOOLSDIRECTORY/PyPy) for pypy in $pypys; do DocumentInstalledItemIndent "PyPy $pypy" -done; +done; \ No newline at end of file diff --git a/images/linux/toolcache-1604.json b/images/linux/toolcache-1604.json index ea7f73c2..40f4cd9d 100644 --- a/images/linux/toolcache-1604.json +++ b/images/linux/toolcache-1604.json @@ -1,14 +1,14 @@ { - "toolcache-python-ubuntu-1604-x64": [ + "@actions/toolcache-python-ubuntu-1604-x64": [ "2.7", "3.5", "3.6", "3.7", "3.8" ], - "toolcache-ruby-ubuntu-1604-x64": [ + "@actions/toolcache-ruby-ubuntu-1604-x64": [ "2.4", "2.5", "2.6", "2.7" ], - "toolcache-pypy-ubuntu-1604-x64": [ + "@actions/toolcache-pypy-ubuntu-1604-x64": [ "2", "3" ], - "toolcache-boost-ubuntu-1604-x64": [ - "1.69" + "@actions/toolcache-boost-ubuntu-1604-x64": [ + "1.69", "1.72" ] } \ No newline at end of file diff --git a/images/linux/toolcache-1804.json b/images/linux/toolcache-1804.json index b076eaf2..26ad4d98 100644 --- a/images/linux/toolcache-1804.json +++ b/images/linux/toolcache-1804.json @@ -1,14 +1,14 @@ { - "toolcache-python-ubuntu-1804-x64": [ + "@actions/toolcache-python-ubuntu-1804-x64": [ "2.7", "3.5", "3.6", "3.7", "3.8" ], - "toolcache-ruby-ubuntu-1804-x64": [ + "@actions/toolcache-ruby-ubuntu-1804-x64": [ "2.4", "2.5", "2.6", "2.7" ], - "toolcache-pypy-ubuntu-1804-x64": [ + "@actions/toolcache-pypy-ubuntu-1804-x64": [ "2", "3" ], - "toolcache-boost-ubuntu-1804-x64": [ - "1.69" + "@actions/toolcache-boost-ubuntu-1804-x64": [ + "1.69", "1.72" ] } \ No newline at end of file diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index da60f370..bca6a3ed 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -21,9 +21,9 @@ "vm_size": "Standard_DS2_v2", "capture_name_prefix": "packer", "image_version": "dev", - "toolcache_registry": "https://buildcanary.pkgs.visualstudio.com/PipelineCanary/_packaging/hostedtoolcache/npm/registry/" + "github_feed_token": null }, - "sensitive-variables": ["client_secret"], + "sensitive-variables": ["client_secret", "github_feed_token"], "builders": [ { "type": "azure-arm", @@ -187,8 +187,8 @@ "environment_vars": [ "METADATA_FILE={{user `metadata_file`}}", "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "TOOLCACHE_REGISTRY={{user `toolcache_registry`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", + "GITHUB_FEED_TOKEN={{user `github_feed_token`}}" ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 2803dd91..5c57731d 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -21,9 +21,9 @@ "vm_size": "Standard_DS2_v2", "capture_name_prefix": "packer", "image_version": "dev", - "toolcache_registry": "https://buildcanary.pkgs.visualstudio.com/PipelineCanary/_packaging/hostedtoolcache/npm/registry/" + "github_feed_token": null }, - "sensitive-variables": ["client_secret"], + "sensitive-variables": ["client_secret", "github_feed_token"], "builders": [ { "type": "azure-arm", @@ -190,8 +190,8 @@ "environment_vars": [ "METADATA_FILE={{user `metadata_file`}}", "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "TOOLCACHE_REGISTRY={{user `toolcache_registry`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", + "GITHUB_FEED_TOKEN={{user `github_feed_token`}}" ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" },