Files
mina-sidor-fa-web/openshift/dev/Jenkinsfile
Erik Tiekstra 0045cafd77 feat(reports): Added report views to view single reports. (TV-205)
Squashed commit of the following:

commit bb28714969a6ac2d2b57134179344169edc1dc1d
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Tue Oct 12 14:15:45 2021 +0200

    Updated routing for signal

commit deb5082659065089c7014c7114538851e13fd6e4
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Tue Oct 12 14:07:33 2021 +0200

    Moved around files

commit 2637261f21968e63fcab4b13cccd8d68ab2ac6fe
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Tue Oct 12 11:22:11 2021 +0200

    Added avvikelse to single report page... also started with refactoring models a bit

commit 53c6a59551bfa0887b22d03419b3434a8c213b50
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Tue Oct 12 09:56:22 2021 +0200

    Implemented frånvaro report

commit e8ccbf15885f0bfa6eb86a9681464a2e04457f99
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Mon Oct 11 16:42:16 2021 +0200

    Added gemensam planering page

commit ebbf6f43ca
Merge: 45aec375 eac45ebd
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Mon Oct 11 15:14:02 2021 +0200

    Merge branch 'next' into develop

commit 45aec3755f
Merge: e4cff086 99c0ac3a
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Mon Oct 11 13:24:11 2021 +0200

    Merge branch 'next' into develop

commit e4cff086c4
Merge: ef10270f 631418bc
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Mon Oct 11 09:47:05 2021 +0200

    Merge branch 'next' into develop

commit ef10270fa9
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Mon Oct 11 09:23:59 2021 +0200

    Removed test build from develop
2021-10-12 14:23:27 +02:00

176 lines
5.9 KiB
Groovy

def cicdproject = "${CICD_NAMESPACE}"
def appname = "${APP_NAME}"
def utv_project = "${UTV_NAMESPACE}"
def auto_project = "${AUTO_NAMESPACE}"
def sys_project = "${SYS_NAMESPACE}"
def test_project = "${TEST_NAMESPACE}"
def jenkinsslave = "nodejs15-agent"
def dist_path = "dist/apps/mina-sidor-fa"
pipeline {
agent {
node {label "${jenkinsslave}"}
}
environment {
CURRENT_COMMIT = getShortCommitHash()
BUILD_TAG = ""
}
stages {
stage("Initialize") {
steps {
echo '### Generating build tag... ###'
script {
def packageJson = readJSON file: 'package.json'
BUILD_TAG = "dev_v${packageJson.version}_${env.BUILD_NUMBER}_${CURRENT_COMMIT}"
echo '### Build tag ###'
echo "This is the build tag: ${BUILD_TAG}"
}
echo '### Build tag generated! ###'
}
}
stage("Install dependencies") {
environment {
NEXUS_CREDS = "${env.NEXUS_USERNAME}:${env.NEXUS_PASSWORD}"
}
steps {
echo '### Installing dependencies... ###'
sh '''
ENCODED=$(echo -n "${NEXUS_CREDS}" | openssl base64)
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
# If we found the cached node_modules, extract the files to node_modules
(test -f node_modules.tar.gz && tar -zxf node_modules.tar.gz && echo "Using cached node_modules from ${CACHE_DIRECTORY}/$(cat hashed.pkg-lock)") || echo "No cached node_modules.tar.gz found"
# Echo to the logs stating that we are using cache
) || 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
'''
echo '### Dependencies installed! ###'
}
}
stage("Build application") {
environment {
NGINX_PATH = "${dist_path}/."
BUILD_TAG = "${BUILD_TAG}"
}
steps {
echo '### Building application... ###'
sh '''
npm run build -- --version ${BUILD_TAG}
cp -r nginx/* ${NGINX_PATH}
'''
echo '### Application built! ###'
}
}
stage('App bake') {
steps {
echo '### Creating image... ###'
script {
openshift.withCluster() {
openshift.withProject(utv_project) {
openshift.selector("bc", "${ appname }").startBuild("--from-dir=${dist_path}", "--wait=true")
openshift.tag("${ appname }:latest", "${ appname }:${BUILD_TAG}")
}
}
}
echo '### Image created! ###'
}
}
stage('Deploy to "auto"') {
steps {
echo '### Deploying to "auto"... ###'
script {
openshift.withCluster() {
openshift.withProject(auto_project) {
openshift.raw("set image dc/${ appname } ${ appname }=docker-registry.default.svc:5000/${utv_project}/${ appname }:${BUILD_TAG} --record=true --source=docker")
openshift.raw("annotate dc ${ appname } version=${BUILD_TAG} --overwrite=true")
openshift.selector("dc", "${ appname }").rollout().status();
}
}
}
echo '### Deployed to "auto"! ###'
}
}
stage('Deploy "sys"') {
steps {
echo '### Deploying to "sys"... ###'
script {
openshift.withCluster() {
openshift.withProject(sys_project) {
openshift.raw("set image dc/${ appname } ${ appname }=docker-registry.default.svc:5000/${utv_project}/${ appname }:${BUILD_TAG} --record=true --source=docker")
openshift.raw("annotate dc ${ appname } version=${BUILD_TAG} --overwrite=true")
openshift.selector("dc", "${ appname }").rollout().status();
}
}
}
echo '### Deployed to "sys"! ###'
}
}
// Temporary while data in sys is so bad
// stage('Deploy to "test"') {
// steps {
// echo '### Deploying to "test"... ###'
// script {
// openshift.withCluster() {
// openshift.withProject(test_project) {
// openshift.raw("set image dc/${ appname } ${ appname }=docker-registry.default.svc:5000/${utv_project}/${ appname }:${BUILD_TAG} --record=true --source=docker")
// openshift.raw("annotate dc ${ appname } version=${BUILD_TAG} --overwrite=true")
// openshift.selector("dc", "${ appname }").rollout().status();
// }
// }
// }
// echo '### Deployed to "test"! ###'
// }
// }
}
}
def getShortCommitHash() {
return sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()
}