reformat jenkinsfile

This commit is contained in:
Drake Marino 2024-06-06 16:41:37 -05:00
parent d5e7de8f50
commit 339f64ac0d

228
Jenkinsfile vendored
View File

@ -1,136 +1,138 @@
pipeline { pipeline {
agent any agent any
parallel { stages {
stages { parallel {
stage('Start API') { stages {
steps { stage('Start API') {
sh '''docker image prune -f
docker build --no-cache -t fbla-api .
docker-compose down
docker-compose up -d'''
}
}
stage('Run Tests') {
steps {
sh '''dart pub install
dart run ./test/fbla_api_test.dart'''
}
}
}
stages {
stage('Flutter Cleanup') {
steps {
sh '''flutter upgrade --force
flutter pub upgrade
flutter --version
flutter doctor
flutter clean'''
}
}
stage('Build') {
parallel {
stage('Web Build') {
steps { steps {
sh 'flutter build web --release --base-href /fbla/' sh '''docker image prune -f
docker build --no-cache -t fbla-api .
docker-compose down
docker-compose up -d'''
} }
} }
stage('Build Linux') { stage('Run Tests') {
steps { steps {
sh 'flutter build linux --release' sh '''dart pub install
} dart run ./test/fbla_api_test.dart'''
}
stage('Build APK') {
steps {
sh 'flutter build apk --release'
} }
} }
} }
} stages {
stage('Flutter Cleanup') {
stage('Deploy and Save') {
parallel {
stage('Deploy Web Local') {
steps { steps {
script { sh '''flutter upgrade --force
def remote = [ flutter pub upgrade
name: 'HostServer', flutter --version
host: '192.168.0.216', flutter doctor
user: '${env.JOBLINK_LOCAL_USER}', flutter clean'''
password: '${env.JOBLINK_LOCAL_PASSWD}', }
allowAnyHosts: true, }
]
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/webfiles/fbla', remote: remote) stage('Build') {
sshPut(from: 'build/web/', into: '/home/${env.JOBLINK_LOCAL_USER}/fbla-webserver', remote: remote) parallel {
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/web /home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/webfiles/fbla" stage('Web Build') {
steps {
sh 'flutter build web --release --base-href /fbla/'
}
} }
}
}
stage('Save Other Builds') { stage('Build Linux') {
steps { steps {
script { sh 'flutter build linux --release'
def remote = [ }
name: 'HostServer', }
host: '192.168.0.216',
user: '${env.JOBLINK_LOCAL_USER}', stage('Build APK') {
password: '${env.JOBLINK_LOCAL_PASSWD}', steps {
allowAnyHosts: true, sh 'flutter build apk --release'
]
if(env.BRANCH_NAME == 'main') {
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/linux', remote: remote)
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux"
sshPut(from: 'build/linux/x64/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/linux', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux"
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux/release/"
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/apk', remote: remote)
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk"
sshPut(from: 'build/app/outputs/apk/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/apk', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk"
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk/release/"
} else {
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux', remote: remote)
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux"
sshPut(from: 'build/linux/x64/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux"
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux/release/"
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk', remote: remote)
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk"
sshPut(from: 'build/app/outputs/apk/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk"
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk/release/"
} }
} }
} }
} }
}
}
stage('Deploy Remote') { stage('Deploy and Save') {
when { parallel {
expression { stage('Deploy Web Local') {
env.BRANCH_NAME == 'main' steps {
script {
def remote = [
name: 'HostServer',
host: '192.168.0.216',
user: '${env.JOBLINK_LOCAL_USER}',
password: '${env.JOBLINK_LOCAL_PASSWD}',
allowAnyHosts: true,
]
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/webfiles/fbla', remote: remote)
sshPut(from: 'build/web/', into: '/home/${env.JOBLINK_LOCAL_USER}/fbla-webserver', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/web /home/${env.JOBLINK_LOCAL_USER}/fbla-webserver/webfiles/fbla"
}
}
}
stage('Save Other Builds') {
steps {
script {
def remote = [
name: 'HostServer',
host: '192.168.0.216',
user: '${env.JOBLINK_LOCAL_USER}',
password: '${env.JOBLINK_LOCAL_PASSWD}',
allowAnyHosts: true,
]
if(env.BRANCH_NAME == 'main') {
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/linux', remote: remote)
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux"
sshPut(from: 'build/linux/x64/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/linux', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux"
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/main/linux/release/"
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/apk', remote: remote)
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk"
sshPut(from: 'build/app/outputs/apk/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/main/apk', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk"
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/main/apk/release/"
} else {
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux', remote: remote)
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux"
sshPut(from: 'build/linux/x64/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux"
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/dev/linux/release/"
sshRemove(path: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk', remote: remote)
sshCommand remote: remote, command: "mkdir /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk"
sshPut(from: 'build/app/outputs/apk/release', into: '/home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk/release/* /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk"
sshCommand remote: remote, command: "rm -R /home/${env.JOBLINK_LOCAL_USER}/builds/dev/apk/release/"
}
}
}
}
}
} }
}
steps { stage('Deploy Remote') {
script { when {
def remote = [ expression {
name: 'MarinoDev', env.BRANCH_NAME == 'main'
host: 'marinodev.com', }
port: 21098, }
user: '${env.JOBLINK_REMOTE_USER}', steps {
identityFile: '/var/jenkins_home/marinoDevPrivateKey', script {
passphrase: '${env.JOBLINK_REMOTE_PASSWD}', def remote = [
allowAnyHosts: true, name: 'MarinoDev',
] host: 'marinodev.com',
sshRemove(path: '/home/${env.JOBLINK_REMOTE_USER}/public_html/fbla', remote: remote) port: 21098,
sshPut(from: '/var/jenkins_home/workspace/fbla-ui_main/build/web/', into: '/home/${env.JOBLINK_REMOTE_USER}/public_html/', remote: remote) user: '${env.JOBLINK_REMOTE_USER}',
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_REMOTE_USER}/public_html/web /home/${env.JOBLINK_REMOTE_USER}/public_html/fbla" identityFile: '/var/jenkins_home/marinoDevPrivateKey',
passphrase: '${env.JOBLINK_REMOTE_PASSWD}',
allowAnyHosts: true,
]
sshRemove(path: '/home/${env.JOBLINK_REMOTE_USER}/public_html/fbla', remote: remote)
sshPut(from: '/var/jenkins_home/workspace/fbla-ui_main/build/web/', into: '/home/${env.JOBLINK_REMOTE_USER}/public_html/', remote: remote)
sshCommand remote: remote, command: "mv /home/${env.JOBLINK_REMOTE_USER}/public_html/web /home/${env.JOBLINK_REMOTE_USER}/public_html/fbla"
}
}
} }
}
} }
} }
} }