gonito-frontend/jenkins/Jenkinsfile-prod

78 lines
1.9 KiB
Plaintext
Raw Normal View History

2022-10-24 08:02:17 +02:00
pipeline {
agent {
docker {
2022-10-24 13:10:17 +02:00
image 'node:lts-bullseye-slim'
2022-10-24 08:02:17 +02:00
}
}
environment {
2022-10-24 09:18:35 +02:00
// ensure production environmental variable are present
2022-10-24 08:02:17 +02:00
CI = 'true'
NODE_ENV = 'production'
2022-10-24 09:18:35 +02:00
// set NPM parameters
2022-10-24 08:11:09 +02:00
HOME = '.'
2022-10-24 09:18:35 +02:00
NPM_CONFIG_CACHE = 'npm_cache'
2022-10-24 09:24:32 +02:00
// set application configuration
2022-10-24 13:10:17 +02:00
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'
sh 'npm install'
2022-10-24 08:02:17 +02:00
sh 'npm clean-install --only=production'
2022-10-24 08:25:01 +02:00
sh 'npm run build'
2022-10-24 08:02:17 +02:00
}
2022-10-24 08:54:05 +02:00
}
stage('Package') {
steps {
2022-10-24 09:18:35 +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 08:46:26 +02:00
stage('SSH-publish-transfer') {
2022-10-24 08:38:09 +02:00
steps {
sshPublisher(
continueOnError: false,
failOnError: true,
publishers: [
sshPublisherDesc(
2022-10-24 13:10:17 +02:00
configName: "mprill-gonito-front-prod",
2022-10-24 08:38:09 +02:00
transfers: [sshTransfer(
2022-10-24 09:18:35 +02:00
remoteDirectory: 'public_html',
// ensure clean deployment by deleting everything in remote directory
2022-10-24 09:11:28 +02:00
cleanRemote: true,
2022-10-24 09:18:35 +02:00
// transfer archive
2022-10-24 09:15:50 +02:00
sourceFiles: 'build.tar.xz',
2022-10-24 09:18:35 +02:00
// unpack archive and clean up
2022-10-24 09:15:50 +02:00
execCommand: 'tar xf public_html/build.tar.xz -C public_html && rm public_html/build.tar.xz'
2022-10-24 08:38:09 +02:00
)],
verbose: true
)
]
)
}
2022-10-24 08:37:32 +02:00
}
2022-10-24 08:46:26 +02:00
stage('SSH-publish-permissions') {
steps {
sshPublisher(
continueOnError: false,
failOnError: true,
publishers: [
sshPublisherDesc(
2022-10-24 13:10:17 +02:00
configName: "mprill-gonito-front-prod",
2022-10-24 09:15:50 +02:00
transfers: [sshTransfer(
2022-10-24 09:18:35 +02:00
// set proper permissions required for hosting
2022-10-24 09:15:50 +02:00
execCommand: 'chmod -R o+rX public_html'
)],
2022-10-24 08:46:26 +02:00
verbose: true
)
]
)
}
}
2022-10-24 08:37:32 +02:00
}
2022-10-24 08:02:17 +02:00
}