plate-tool/Jenkinsfile

50 lines
1.1 KiB
Groovy

pipeline {
agent any
environment {
OUTPUT_DIR = "${env.BRANCH_NAME == "main" ? "plate-tool" : "plate-tool-beta"}"
}
stages {
stage('Parent') {
when { anyOf { branch 'main'; branch 'beta-release' } }
stages {
stage('Build') {
steps {
sh '''
. "$HOME/.cargo/env"
cd plate-tool-web
trunk build --release --public-url "./"
'''
}
}
stage('Archive') {
steps {
zip zipFile: "dist.zip", archive: true, dir: "plate-tool-web/dist/"
archiveArtifacts artifacts: "dist.zip", fingerprint: true
}
}
stage('Transfer') {
steps {
sh 'echo "put -r plate-tool-web/dist/" | sftp oracle'
}
}
stage('Deploy') {
steps {
sh '''
ssh oracle "sudo rm -rf /usr/share/nginx/html/$OUTPUT_DIR/ && sudo mv dist /usr/share/nginx/html/$OUTPUT_DIR"
'''
}
}
}
}
}
post {
always {
cleanWs(notFailBuild: true,
deleteDirs: true,
cleanWhenNotBuilt: false,
patterns: [[pattern: 'target/', type: 'EXCLUDE']])
}
}
}