2022-10-24 08:02:17 +02:00
|
|
|
pipeline {
|
|
|
|
agent {
|
|
|
|
docker {
|
2023-01-12 18:22:09 +01:00
|
|
|
image 'node:lts-bullseye'
|
2022-10-24 08:02:17 +02:00
|
|
|
}
|
|
|
|
}
|
2022-10-24 14:53:32 +02:00
|
|
|
environment {
|
|
|
|
// ensure production environmental variable are present
|
2022-10-24 08:02:17 +02:00
|
|
|
CI = 'true'
|
2022-10-24 14:53:32 +02:00
|
|
|
NODE_ENV = 'production'
|
|
|
|
// set NPM parameters
|
|
|
|
HOME = '.'
|
|
|
|
NPM_CONFIG_CACHE = 'npm_cache'
|
|
|
|
// set application configuration
|
|
|
|
REACT_APP_KC_URL = 'https://auth.csi.wmi.amu.edu.pl/'
|
|
|
|
REACT_APP_KC_REALM = 'csi-gonito'
|
|
|
|
REACT_APP_KC_CLIENT_ID = 'gonito-frontend'
|
2022-10-24 08:02:17 +02:00
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Build') {
|
|
|
|
steps {
|
2022-10-24 08:37:32 +02:00
|
|
|
//sh 'npm install --loglevel=verbose'
|
2022-10-24 14:53:32 +02:00
|
|
|
sh 'npm install'
|
|
|
|
sh 'npm clean-install --only=production'
|
|
|
|
sh 'npm run build'
|
2022-10-24 08:02:17 +02:00
|
|
|
}
|
2022-10-24 08:54:05 +02:00
|
|
|
}
|
2022-10-24 14:53:32 +02:00
|
|
|
stage('Package') {
|
2022-10-24 08:54:05 +02:00
|
|
|
steps {
|
2022-10-24 14:53:32 +02:00
|
|
|
// due to involved path processing of sshPublisher it's easier to pack everything into an archive
|
2022-10-24 09:15:50 +02:00
|
|
|
sh 'cd build && tar cf ../build.tar.xz .'
|
2022-10-24 08:54:05 +02:00
|
|
|
}
|
2022-10-24 08:02:17 +02:00
|
|
|
}
|
2022-10-24 14:53:32 +02:00
|
|
|
stage('SSH-publish-transfer') {
|
|
|
|
steps {
|
|
|
|
sshPublisher(
|
|
|
|
continueOnError: false,
|
|
|
|
failOnError: true,
|
|
|
|
publishers: [
|
|
|
|
sshPublisherDesc(
|
|
|
|
configName: "mprill-gonito-front-prod",
|
|
|
|
transfers: [sshTransfer(
|
|
|
|
remoteDirectory: 'public_html',
|
|
|
|
// ensure clean deployment by deleting everything in remote directory
|
|
|
|
cleanRemote: true,
|
|
|
|
// transfer archive
|
|
|
|
sourceFiles: 'build.tar.xz',
|
|
|
|
// unpack archive and clean up
|
|
|
|
execCommand: 'tar xf public_html/build.tar.xz -C public_html && rm public_html/build.tar.xz'
|
|
|
|
)],
|
|
|
|
verbose: true
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('SSH-publish-permissions') {
|
|
|
|
steps {
|
|
|
|
sshPublisher(
|
|
|
|
continueOnError: false,
|
|
|
|
failOnError: true,
|
|
|
|
publishers: [
|
|
|
|
sshPublisherDesc(
|
|
|
|
configName: "mprill-gonito-front-prod",
|
|
|
|
transfers: [sshTransfer(
|
|
|
|
// set proper permissions required for hosting
|
|
|
|
execCommand: 'chmod -R o+rX public_html'
|
|
|
|
)],
|
|
|
|
verbose: true
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-24 08:02:17 +02:00
|
|
|
}
|
|
|
|
|