diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..ae589f3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,137 @@ +pipeline { + agent any + 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('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 { + 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: '${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/" + } + } + } + } + } + } + + 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" + } + } + } + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index 77798c6..349f708 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ It uses the [Flutter Framework](https://flutter.dev/) for the front end and the - Stable internet connection. ### API -- **OS**: Windows, Linux, MacOS +- **OS**: Windows, Linux, MacOS. - Stable internet connection. ## Installation/Usage @@ -33,7 +33,7 @@ Please view the README in [fbla_ui](fbla_ui/README.md) and [fbla-api](fbla-api/R ## Competitions -[Here](https://docs.google.com/presentation/d/1ZbSE9RqobU2T-NDIm3CUtT_9nEhOm3_B47NZl1-c_QA) is the presentation used for competitions +[Here](https://docs.google.com/presentation/d/1ZbSE9RqobU2T-NDIm3CUtT_9nEhOm3_B47NZl1-c_QA) is the presentation used for competitions. ### WI State Leadership Conference diff --git a/fbla-api/Jenkinsfile b/fbla-api/Jenkinsfile index a53a593..29340c9 100644 --- a/fbla-api/Jenkinsfile +++ b/fbla-api/Jenkinsfile @@ -16,6 +16,5 @@ docker-compose up -d''' dart run ./test/fbla_api_test.dart''' } } - } } \ No newline at end of file diff --git a/fbla-api/README.md b/fbla-api/README.md index 0211439..d222c6a 100644 --- a/fbla-api/README.md +++ b/fbla-api/README.md @@ -2,15 +2,15 @@ This is the API for my 2023-2024 FBLA Coding & Programming App ## Installation -1. Install [Dart SDK](https://dart.dev/get-dart) -2. Clone the repo +1. Install [Dart SDK](https://dart.dev/get-dart). +2. Clone the repo . ```bash git clone https://git.marinodev.com/MarinoDev/FBLA24.git cd FBLA24/fbla-api/ ``` -3. Run `dart pub install` to install dart packages +3. Run `dart pub install` to install dart packages. 4. Install [PostgreSQL](https://www.postgresql.org/) and set it up. -5. Create `fbla` database in postgres +5. Create `fbla` database in postgres. ```SQL CREATE DATABASE fbla WITH @@ -21,7 +21,7 @@ CREATE DATABASE fbla ``` Make sure to change [username] to the actual username of your postgres instance. -6. Create `businesses` table +6. Create `businesses` table. ```SQL -- Table: public.businesses @@ -48,8 +48,9 @@ TABLESPACE pg_default; ALTER TABLE IF EXISTS public.businesses OWNER to [username]; ``` -Make sure to change [username] to the actual username of your postgres instance -7. Create `users` table +Make sure to change [username] to the actual username of your postgres instance. + +7. Create `users` table. ```SQL -- Table: public.users @@ -70,8 +71,8 @@ ALTER TABLE IF EXISTS public.users OWNER to postgres; ``` 8. Set environment variables `JOBLINK_POSTGRES_ADDRESS` (IP address), `JOBLINK_POSTGRES_PORT` (default 5432), `JOBLINK_POSTGRES_USERNAME`, and `JOBLINK_POSTGRES_PASSWORD` to appropriate information for your postgres database. Also set `JOBLINK_SECRET_KEY` to anything you want to generate JSON Web Tokens. -9. Set lib/create_first_user.dart username and password variables at top of file and run with `dart run lib/create_first_user.dart` -Note: the username and password you use here will be what you use to log into the app as an admin +9. Set lib/create_first_user.dart username and password variables at top of file and run with `dart run lib/create_first_user.dart`.\ +Note: the username and password you use here will be what you use to log into the app as an admin. ## Usage diff --git a/fbla_ui/Jenkinsfile b/fbla_ui/Jenkinsfile index 6d80f42..c088113 100644 --- a/fbla_ui/Jenkinsfile +++ b/fbla_ui/Jenkinsfile @@ -1,125 +1,4 @@ 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: '${env.JOBLINK_LOCAL_USER}', - password: '${env.JOBLINK_LOCAL_PASSWD}', - 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: '${env.JOBLINK_REMOTE_USER}', - identityFile: '/var/jenkins_home/marinoDevPrivateKey', - passphrase: '${env.JOBLINK_REMOTE_PASSWD}', - 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" - } - - } - } - - } } \ No newline at end of file