Jenkinsfile.

This commit is contained in:
Maciej Prill 2022-10-24 09:18:35 +02:00
parent aaae26c9ee
commit e1c4911f53

13
Jenkinsfile vendored
View File

@ -5,10 +5,12 @@ pipeline {
} }
} }
environment { environment {
// ensure production environmental variable are present
CI = 'true' CI = 'true'
NODE_ENV = 'production' NODE_ENV = 'production'
// set NPM parameters
HOME = '.' HOME = '.'
npm_config_cache = 'npm_cache' NPM_CONFIG_CACHE = 'npm_cache'
} }
stages { stages {
stage('Build') { stage('Build') {
@ -21,6 +23,7 @@ pipeline {
} }
stage('Package') { stage('Package') {
steps { steps {
// due to involved path processing of sshPublisher it's easier to pack everything into an archive
sh 'cd build && tar cf ../build.tar.xz .' sh 'cd build && tar cf ../build.tar.xz .'
} }
} }
@ -33,9 +36,12 @@ pipeline {
sshPublisherDesc( sshPublisherDesc(
configName: "mprill-gonito-front-dev", configName: "mprill-gonito-front-dev",
transfers: [sshTransfer( transfers: [sshTransfer(
cleanRemote: true,
sourceFiles: 'build.tar.xz',
remoteDirectory: 'public_html', 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' execCommand: 'tar xf public_html/build.tar.xz -C public_html && rm public_html/build.tar.xz'
)], )],
verbose: true verbose: true
@ -53,6 +59,7 @@ pipeline {
sshPublisherDesc( sshPublisherDesc(
configName: "mprill-gonito-front-dev", configName: "mprill-gonito-front-dev",
transfers: [sshTransfer( transfers: [sshTransfer(
// set proper permissions required for hosting
execCommand: 'chmod -R o+rX public_html' execCommand: 'chmod -R o+rX public_html'
)], )],
verbose: true verbose: true