plate-tool/Jenkinsfile

52 lines
1.0 KiB
Groovy

pipeline {
agent any
stages {
stage('Setup') {
if (env.BRANCH_NAME == 'main') {
environment {
OUTPUT_DIR = 'plate-tool'
}
} else {
environment {
OUTPUT_DIR = 'plate-tool-beta'
}
}
}
stage('Build') {
steps {
sh '''
. "$HOME/.cargo/env"
trunk build --release --public-url "cool-stuff/$OUTPUT_DIR/"
'''
}
}
stage('Archive') {
steps {
zip zipFile: "dist.zip", archive: true, dir: "dist/"
archiveArtifacts artifacts: "dist.zip", fingerprint: true
}
}
stage('Transfer') {
steps {
sh 'echo "put -r 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']])
}
}
}