Test just running npm install
This commit is contained in:
42
openshift/dev/Jenkinsfile
vendored
42
openshift/dev/Jenkinsfile
vendored
@@ -44,46 +44,8 @@ pipeline {
|
||||
CACHE_DIRECTORY=/home/jenkins/.npm/cache
|
||||
mkdir -p ${CACHE_DIRECTORY}
|
||||
echo "_auth=${ENCODED}" >> .npmrc
|
||||
# set -x
|
||||
cat .npmrc
|
||||
|
||||
# Pull from cache if it exists
|
||||
(
|
||||
# Fail if any step fail
|
||||
set -e
|
||||
# Remove line 3 from package-lock, which contain the package.json version. Store backup.
|
||||
# We only care about dependencies, not the version
|
||||
sed -i.bak -e '3d' package-lock.json
|
||||
# Hash the package-lock.json file
|
||||
sha1sum package-lock.json | tr -s " " | awk '{print $1}' > hashed.pkg-lock
|
||||
# Restore package-lock.json with version number intact
|
||||
mv package-lock.json.bak package-lock.json
|
||||
# Try to get the file from cache
|
||||
cp ${CACHE_DIRECTORY}/$(cat hashed.pkg-lock) node_modules.tar.gz 2> /dev/null
|
||||
# Check if we found the cached node_modules
|
||||
test -f node_modules.tar.gz
|
||||
# If we found the cached node_modules, extract the files to node_modules
|
||||
tar -zxf node_modules.tar.gz
|
||||
# Echo to the logs stating that we are using cache
|
||||
echo "Using cached node_modules from ${CACHE_DIRECTORY}/$(cat hashed.pkg-lock)"
|
||||
) || true
|
||||
|
||||
# If we did not find the cached node_modules, install from the lock
|
||||
test -f node_modules.tar.gz || npm ci;
|
||||
|
||||
# Store cache
|
||||
(
|
||||
# Fail if any step fail
|
||||
set -e
|
||||
# Only update the cache if we found no previous cache
|
||||
test ! -f node_modules.tar.gz
|
||||
# Tar the cache
|
||||
tar -zcf node_modules.tar.gz node_modules
|
||||
# Clean old cache
|
||||
rm -rf ${CACHE_DIRECTORY}/*
|
||||
# Store the cache
|
||||
cp node_modules.tar.gz ${CACHE_DIRECTORY}/$(cat hashed.pkg-lock)
|
||||
) || true
|
||||
|
||||
npm install
|
||||
'''
|
||||
echo '### Dependencies installed! ###'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user