From 877d5feff71487e89733e6baf8ba0f523af04ffc Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Mon, 12 Sep 2016 14:32:12 -0400 Subject: [PATCH] ci: install the correct node.js version via nvm (elastic/elasticsearch#3229) This will ensure that CI runs the Kibana plugin tests with the appropriate version of node.js. Original commit: elastic/x-pack-elasticsearch@aeb7399f919fee331fd30336016086cdb5dcddd3 --- dev-tools/ci | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/dev-tools/ci b/dev-tools/ci index 611f30c6ab5..994699bd820 100755 --- a/dev-tools/ci +++ b/dev-tools/ci @@ -4,9 +4,13 @@ # It will attempt to check out 'elasticsearch' into a sibling directory # unless the environment variable `USE_EXISTING_ES` has a value # +# It will also attempt to install the appropriate version of node.js +# for the Kibana plugin tests using nvm. Set a custom nvm directory +# using the `NVM_DIR` environment variable. +# # Turn on semi-strict mode -set -euf pipefail +set -e pipefail SCRIPT="$0" @@ -51,11 +55,30 @@ else fi fi +# back to base directory +cd "$BASE_DIR" + +# install the correct node.js version +if [ -z ${NVM_DIR:+x} ]; then + export NVM_DIR="/var/lib/jenkins/.nvm"; +fi + +NVM_SCRIPT="$NVM_DIR/nvm.sh" +if [ -s "$NVM_SCRIPT" ]; then + . "$NVM_SCRIPT" # load nvm +else + echo "Unable to find the nvm script at \"$NVM_SCRIPT\"" + exit 1 +fi + +echo "Installing node.js version $(cat ./kibana/.node-version)..." +nvm install "$(cat ./kibana/.node-version)" + echo "Running X-Plugins tests..." -cd "$BASE_DIR" && echo "Running in $PWD" +echo "Running in $PWD" # output the commands -set -x +set -xuf # clean gradle --stacktrace clean