diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 049098b2..1effe988 100644 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -1,10 +1,28 @@ #!/bin/bash +NODE_REQUIRED_VERSION=v12.13.1 + if ! [ -x "$(command -v git)" ]; then echo 'GIT does not exist! Please set it up before running this script!' >&2 exit 1 fi +# Switch to the appropriate node version for the branch using NVM +if [ -x "$(command -v nvm)" ]; then + echo 'NVM does not not exist! Install it to switch to the appropriate node version!' >&2 + exit 1 +fi + +# Source all the profile files to ensure nvm is in path +source $HOME/.nvm/nvm.sh + +NODE_CURRENT_VERSION=$(nvm current) +if [ "$NODE_REQUIRED_VERSION" != "$NODE_CURRENT_VERSION" ]; then + echo 'Node version does not match required version! Installing the required version' >&2 + nvm install $NODE_REQUIRED_VERSION + nvm use $NODE_REQUIRED_VERSION +fi + if ! [ -x "$(command -v node)" ]; then echo 'NODE does not exist! Please set it up before running this script!' >&2 exit 1 diff --git a/scripts/build-mac.sh b/scripts/build-mac.sh index 3b9436bb..bf6b1dab 100755 --- a/scripts/build-mac.sh +++ b/scripts/build-mac.sh @@ -1,10 +1,29 @@ #!/bin/bash +NODE_REQUIRED_VERSION=v12.13.1 + +# Check basic dependencies if ! [ -x "$(command -v git)" ]; then echo 'GIT does not exist! Please set it up before running this script!' >&2 exit 1 fi +# Switch to the appropriate node version for the branch using NVM +if [ -x "$(command -v nvm)" ]; then + echo 'NVM does not not exist! Install it to switch to the appropriate node version!' >&2 + exit 1 +fi + +# Source all the profile files to ensure nvm is in path +source $HOME/.nvm/nvm.sh + +NODE_CURRENT_VERSION=$(nvm current) +if [ "$NODE_REQUIRED_VERSION" != "$NODE_CURRENT_VERSION" ]; then + echo 'Node version does not match required version! Installing the required version' >&2 + nvm install $NODE_REQUIRED_VERSION + nvm use $NODE_REQUIRED_VERSION +fi + if ! [ -x "$(command -v node)" ]; then echo 'NODE does not exist! Please set it up before running this script!' >&2 exit 1 @@ -15,24 +34,26 @@ if ! [ -x "$(command -v npm)" ]; then exit 1 fi -if ! [ -x "$(command -v /usr/local/bin/packagesbuild)" ]; then - echo 'Packages build does not exist! Please set it up before running this script!' >&2 - exit 1 -fi - if ! [ -x "$(command -v gulp)" ]; then echo 'Gulp does not exist! Install it for setting expiry!' >&2 exit 1 fi +if ! [ -x "$(command -v /usr/local/bin/packagesbuild)" ]; then + echo 'Packages build does not exist! Please set it up before running this script!' >&2 + exit 1 +fi + +# If we don't get parent build number from parent job, set it to 0 if [ -z "$PARENT_BUILD_VERSION" ]; then echo "PARENT_BUILD_VERSION is empty, setting default" PARENT_BUILD_VERSION="0" fi NODE_VERSION=$(node --version) -echo "Node Version: ${NODE_VERSION}" +echo "Executing using Node Version: ${NODE_VERSION}" +# We need to include swift search libraries to build SDA if [ ! -d "$HOME/tronlibraries/library" ]; then echo 'Search libraries do not exist! Not building with swift search' >&2 else @@ -44,22 +65,26 @@ PKG_VERSION=$(node -e "console.log(require('./package.json').version);") # Install app dependencies npm install -# replace url in config +# Replace url in config echo "Setting default pod url to https://corporate.symphony.com" sed -i -e 's/\"url\"[[:space:]]*\:[[:space:]]*\".*\"/\"url\":\"https:\/\/corporate.symphony.com\"/g' config/Symphony.config -# setup the build version + +# Setup the build version echo "Setting build version to ${PARENT_BUILD_VERSION}" sed -i -e "s/\"buildNumber\"[[:space:]]*\:[[:space:]]*\".*\"/\"buildNumber\":\" ${PARENT_BUILD_VERSION}\"/g" package.json -# replace version number in pre-install script + +# Replace version number in pre-install script echo "Setting package version in pre install script to ${PKG_VERSION}" sed -i -e "s/CURRENT_VERSION=APP_VERSION/CURRENT_VERSION=${PKG_VERSION}/g" ./installer/mac/preinstall.sh +# Set expiry period for TTL builds if [ -z "$EXPIRY_PERIOD" ]; then echo 'Expiry period not set, so, not creating expiry for the build' else gulp setExpiry --period ${EXPIRY_PERIOD} fi +# Build the app echo "Running tests, code coverage, linting and building..." npm run unpacked-mac diff --git a/scripts/build-win32.bat b/scripts/build-win32.bat index bf073ff1..cd2e0afd 100644 --- a/scripts/build-win32.bat +++ b/scripts/build-win32.bat @@ -5,6 +5,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd echo %PATH% set DISABLE_REBUILD=true +set NODE_REQUIRED_VERSION=12.13.1 set PATH=%PATH%;C:\Program Files\nodejs\;C:\Program Files\Git\cmd echo %PATH% @@ -18,6 +19,15 @@ if %ERRORLEVEL% NEQ 0 ( EXIT /B 1 ) +WHERE nvm +if %ERRORLEVEL% NEQ 0 ( + echo "NVM does not exist. Please set it up before running this script." + EXIT /B 1 +) + +nvm install %NODE_REQUIRED_VERSION% +nvm use %NODE_REQUIRED_VERSION% + WHERE node if %ERRORLEVEL% NEQ 0 ( echo "NODE does not exist. Please set it up before running this script." @@ -30,12 +40,17 @@ if %ERRORLEVEL% NEQ 0 ( EXIT /B 1 ) +call npm i -g gulp-cli + WHERE gulp if %ERRORLEVEL% NEQ 0 ( echo "GULP does not exist. Please set it up before running this script." EXIT /B 1 ) +echo "Node version is: " +call node --version + :: Below command replaces buildVersion with the appropriate build number from jenkins sed -i -e "s/\"buildNumber\"[[:space:]]*\:[[:space:]]*\".*\"/\"buildNumber\":\"%PARENT_BUILD_VERSION%\"/g" package.json @@ -46,8 +61,6 @@ echo D | xcopy /y "C:\jenkins\workspace\tronlibraries\library" "library" echo "Running npm install..." call npm install -call npm i -g gulp-cli - :: Set expiry if required IF "%EXPIRY_PERIOD%"=="" ( echo "Not setting expiry for the build!" diff --git a/scripts/build-win64.bat b/scripts/build-win64.bat index ea5f694f..31e0348b 100644 --- a/scripts/build-win64.bat +++ b/scripts/build-win64.bat @@ -5,6 +5,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd echo %PATH% set DISABLE_REBUILD=true +set NODE_REQUIRED_VERSION=12.13.1 set PATH=%PATH%;C:\Program Files\nodejs\;C:\Program Files\Git\cmd echo %PATH% @@ -18,6 +19,15 @@ if %ERRORLEVEL% NEQ 0 ( EXIT /B 1 ) +WHERE nvm +if %ERRORLEVEL% NEQ 0 ( + echo "NVM does not exist. Please set it up before running this script." + EXIT /B 1 +) + +nvm install %NODE_REQUIRED_VERSION% +nvm use %NODE_REQUIRED_VERSION% + WHERE node if %ERRORLEVEL% NEQ 0 ( echo "NODE does not exist. Please set it up before running this script." @@ -30,12 +40,17 @@ if %ERRORLEVEL% NEQ 0 ( EXIT /B 1 ) +call npm i -g gulp-cli + WHERE gulp if %ERRORLEVEL% NEQ 0 ( echo "GULP does not exist. Please set it up before running this script." EXIT /B 1 ) +echo "Node version is: " +call node --version + :: Below command replaces buildVersion with the appropriate build number from jenkins sed -i -e "s/\"buildNumber\"[[:space:]]*\:[[:space:]]*\".*\"/\"buildNumber\":\"%PARENT_BUILD_VERSION%\"/g" package.json @@ -46,8 +61,6 @@ echo D | xcopy /y "C:\jenkins\workspace\tronlibraries\library" "library" echo "Running npm install..." call npm install -call npm i -g gulp-cli - :: Set expiry if required IF "%EXPIRY_PERIOD%"=="" ( echo "Not setting expiry for the build!"