reformat jenkinsfile again x2

This commit is contained in:
Drake Marino 2024-06-06 18:06:47 -05:00
parent 355a5b2532
commit 5fe4201060
2 changed files with 228 additions and 104 deletions

211
Jenkinsfile vendored
View File

@ -1,7 +1,7 @@
pipeline {
agent any
stages {
stage('Flutter Cleanup') {
stage('Flutter Cleanup/Update') {
steps {
sh '''flutter upgrade --force
flutter pub upgrade
@ -10,129 +10,132 @@ pipeline {
flutter clean'''
}
}
parallel {
stages {
stage('Start API') {
steps {
sh '''docker image prune -f
docker build --no-cache -t fbla-api .
docker-compose down
docker-compose up -d'''
}
}
stage('Build API & UI') {
stage('Run Tests') {
steps {
sh '''dart pub install
dart run ./test/fbla_api_test.dart'''
}
}
}
stages {
stage('Build') {
parallel {
stage('Web Build') {
parallel {
stages {
stage('Start API') {
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 {
sh 'flutter build linux --release'
}
}
stage('Build APK') {
steps {
sh 'flutter build apk --release'
sh '''dart pub install
dart run ./test/fbla_api_test.dart'''
}
}
}
}
stage('Deploy and Save') {
parallel {
stage('Deploy Web Local') {
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"
stages {
stage('Build') {
parallel {
stage('Web Build') {
steps {
sh 'flutter build web --release --base-href /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/"
stage('Build Linux') {
steps {
sh 'flutter build linux --release'
}
}
stage('Build APK') {
steps {
sh 'flutter build apk --release'
}
}
}
}
}
}
stage('Deploy Remote') {
when {
expression {
env.BRANCH_NAME == 'main'
stage('Deploy and Save') {
parallel {
stage('Deploy Web Local') {
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 {
script {
def remote = [
name: 'MarinoDev',
host: 'marinodev.com',
port: 21098,
user: '${env.JOBLINK_REMOTE_USER}',
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"
stage('Deploy Remote') {
when {
expression {
env.BRANCH_NAME == 'main'
}
}
steps {
script {
def remote = [
name: 'MarinoDev',
host: 'marinodev.com',
port: 21098,
user: '${env.JOBLINK_REMOTE_USER}',
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"
}
}
}
}
}
}
}
}
}

121
fbla_ui/Jenkinsfile vendored
View File

@ -1,4 +1,125 @@
pipeline {
agent any
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 {
sh 'flutter build web --release --base-href /fbla/'
}
}
stage('Build Linux') {
steps {
sh 'flutter build linux --release'
}
}
stage('Build APK') {
steps {
sh 'flutter build apk --release'
}
}
}
}
stage('Deploy and Save') {
parallel {
stage('Deploy Web Local') {
steps {
script {
def remote = [
name: 'HostServer',
host: '192.168.0.216',
user: 'fbla',
password: 'fbla',
allowAnyHosts: true,
]
sshRemove(path: '/home/fbla/fbla-webserver/webfiles/fbla', remote: remote)
sshPut(from: 'build/web/', into: '/home/fbla/fbla-webserver', remote: remote)
sshCommand remote: remote, command: "mv /home/fbla/fbla-webserver/web /home/fbla/fbla-webserver/webfiles/fbla"
}
}
}
stage('Save Other Builds') {
steps {
script {
def remote = [
name: 'HostServer',
host: '192.168.0.216',
user: 'fbla',
password: 'fbla',
allowAnyHosts: true,
]
if(env.BRANCH_NAME == 'main') {
sshRemove(path: '/home/fbla/builds/main/linux', remote: remote)
sshCommand remote: remote, command: "mkdir /home/fbla/builds/main/linux"
sshPut(from: 'build/linux/x64/release', into: '/home/fbla/builds/main/linux', remote: remote)
sshCommand remote: remote, command: "mv /home/fbla/builds/main/linux/release/* /home/fbla/builds/main/linux"
sshCommand remote: remote, command: "rm -R /home/fbla/builds/main/linux/release/"
sshRemove(path: '/home/fbla/builds/main/apk', remote: remote)
sshCommand remote: remote, command: "mkdir /home/fbla/builds/main/apk"
sshPut(from: 'build/app/outputs/apk/release', into: '/home/fbla/builds/main/apk', remote: remote)
sshCommand remote: remote, command: "mv /home/fbla/builds/main/apk/release/* /home/fbla/builds/main/apk"
sshCommand remote: remote, command: "rm -R /home/fbla/builds/main/apk/release/"
} else {
sshRemove(path: '/home/fbla/builds/dev/linux', remote: remote)
sshCommand remote: remote, command: "mkdir /home/fbla/builds/dev/linux"
sshPut(from: 'build/linux/x64/release', into: '/home/fbla/builds/dev/linux', remote: remote)
sshCommand remote: remote, command: "mv /home/fbla/builds/dev/linux/release/* /home/fbla/builds/dev/linux"
sshCommand remote: remote, command: "rm -R /home/fbla/builds/dev/linux/release/"
sshRemove(path: '/home/fbla/builds/dev/apk', remote: remote)
sshCommand remote: remote, command: "mkdir /home/fbla/builds/dev/apk"
sshPut(from: 'build/app/outputs/apk/release', into: '/home/fbla/builds/dev/apk', remote: remote)
sshCommand remote: remote, command: "mv /home/fbla/builds/dev/apk/release/* /home/fbla/builds/dev/apk"
sshCommand remote: remote, command: "rm -R /home/fbla/builds/dev/apk/release/"
}
}
}
}
}
}
stage('Deploy Remote') {
when {
expression {
env.BRANCH_NAME == 'main'
}
}
steps {
script {
def remote = [
name: 'MarinoDev',
host: 'marinodev.com',
port: 21098,
user: 'mariehdi',
identityFile: '/var/jenkins_home/marinoDevPrivateKey',
passphrase: 'marinodev',
allowAnyHosts: true,
]
sshRemove(path: '/home/mariehdi/public_html/fbla', remote: remote)
sshPut(from: '/var/jenkins_home/workspace/fbla-ui_main/build/web/', into: '/home/mariehdi/public_html/', remote: remote)
sshCommand remote: remote, command: "mv /home/mariehdi/public_html/web /home/mariehdi/public_html/fbla"
}
}
}
}
}