[dev/ci_setup] generalize jenkins_setup script for other CI environments (#15178)
* [dev/ci_setup] generalize jenkins_setup script for other CI environments * [dev/ci_setup] accept more general `CACHE_DIR` env arg * [dev/ci_setup] node.js install might not be invalid
This commit is contained in:
parent
a6b41838b5
commit
999126373f
53
src/dev/ci_setup/setup.sh
Executable file
53
src/dev/ci_setup/setup.sh
Executable file
|
@ -0,0 +1,53 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
dir="$(pwd)"
|
||||||
|
cacheDir="${CACHE_DIR:-"/tmp/kibana"}"
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### check that we seem to be in a kibana project
|
||||||
|
###
|
||||||
|
if [ -f "$dir/package.json" ] && [ -f "$dir/.node-version" ]; then
|
||||||
|
echo "Setting up node.js and npm in $dir"
|
||||||
|
else
|
||||||
|
echo "src/dev/ci_setup/setup.sh must be run within a kibana repo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### download node
|
||||||
|
###
|
||||||
|
nodeVersion="$(cat $dir/.node-version)"
|
||||||
|
nodeUrl="https://nodejs.org/download/release/v$nodeVersion/node-v$nodeVersion-linux-x64.tar.gz"
|
||||||
|
nodeDir="$cacheDir/node/$nodeVersion"
|
||||||
|
echo " -- node: version=v${nodeVersion} dir=$nodeDir"
|
||||||
|
|
||||||
|
echo " -- setting up node.js"
|
||||||
|
if [ -x "$nodeDir/bin/node" ] && [ "$($nodeDir/bin/node --version)" == "v$nodeVersion" ]; then
|
||||||
|
echo " -- reusing node.js install"
|
||||||
|
else
|
||||||
|
if [ -d "$nodeDir" ]; then
|
||||||
|
echo " -- clearing previous node.js install"
|
||||||
|
rm -rf "$nodeDir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo " -- downloading node.js from $nodeUrl"
|
||||||
|
mkdir -p "$nodeDir"
|
||||||
|
curl --silent "$nodeUrl" | tar -xz -C "$nodeDir" --strip-components=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### "install" node by extending the path with it's bin directory
|
||||||
|
###
|
||||||
|
export PATH="$nodeDir/bin:$PATH"
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### install dependencies
|
||||||
|
###
|
||||||
|
echo " -- installing node.js dependencies"
|
||||||
|
npm install --cache "$cacheDir/npm"
|
|
@ -1,39 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
###*****###
|
|
||||||
### CWD ###
|
|
||||||
###*****###
|
|
||||||
if [ -n "$WORKSPACE" ]; then
|
|
||||||
cd "$WORKSPACE"
|
|
||||||
else
|
|
||||||
echo "Unable to find the $WORKSPACE environment variable, is this jenkins?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
###*****###
|
|
||||||
### NVM ###
|
|
||||||
###*****###
|
|
||||||
export NVM_DIR="/var/lib/jenkins/.nvm"
|
|
||||||
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
|
|
||||||
|
|
||||||
nvm install "$(cat .node-version)"
|
|
||||||
|
|
||||||
###*****###
|
|
||||||
### NPM ###
|
|
||||||
###*****###
|
|
||||||
npm install
|
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$(npm bin)" ]; then
|
|
||||||
echo "npm does not know where it stores executables..... huh??"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
source "$(dirname $0)/_jenkins_setup.sh"
|
source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"
|
||||||
|
|
||||||
"$(npm bin)/grunt" jenkins:docs;
|
"$(npm bin)/grunt" jenkins:docs;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
source "$(dirname $0)/_jenkins_setup.sh"
|
source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"
|
||||||
|
|
||||||
"$(npm bin)/grunt" build --release;
|
"$(npm bin)/grunt" build --release;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
source "$(dirname $0)/_jenkins_setup.sh"
|
source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"
|
||||||
|
|
||||||
xvfb-run "$(npm bin)/grunt" jenkins:unit;
|
xvfb-run "$(npm bin)/grunt" jenkins:unit;
|
||||||
|
|
Loading…
Reference in a new issue