Compare commits

...

47 Commits

Author SHA1 Message Date
bucky 15a5017c86 set up to run with only the freebsd and ruby labeled agent(s) 2023-10-18 13:08:41 -07:00
bucky dd5caa4056 updated README, swapped Falcon for Puma for now, and ignored more files 2023-10-17 21:53:12 -07:00
bucky 360ddbe6d2 include the branch name in the zip, so it can be identified a little easier later 2023-10-17 21:45:14 -07:00
bucky b3b886f0b3 Merge pull request 'simplify-secret' (#27) from simplify-secret into master
Reviewed-on: #27
2023-10-17 21:43:19 -07:00
bucky 93aa007c14 removed secret.rb, it's no longer needed 2023-10-17 21:40:39 -07:00
bucky 4e32f4a60d use the escaped quotes for it to work correctly 2023-10-17 21:39:15 -07:00
bucky 2759880a53 remove env. 2023-10-17 21:37:45 -07:00
bucky 7bc1a852db swap quotes on the db name 2023-10-17 21:36:56 -07:00
bucky 00119f9723 use env.DB_NAME to access the environment variable 2023-10-17 21:32:30 -07:00
bucky ff2a0e867d swap the quotes because single quotes doesn't exec the ruby command 2023-10-17 21:30:53 -07:00
bucky 1fae85ff9d moved the init step into one shell command to load it all, and don't use
the secret.rb file
2023-10-17 21:26:23 -07:00
bucky 10fe82ab6a Merge pull request 'archive-deliverable' (#26) from archive-deliverable into master
Reviewed-on: #26
2023-10-17 18:12:37 -07:00
bucky 9812a92d59 remove ls 2023-10-17 18:09:17 -07:00
bucky e8b12c307a include ruby version 2023-10-17 18:06:36 -07:00
bucky ae00ac8672 forgot the .rb 2023-10-17 18:04:29 -07:00
bucky bf92201721 removed some unnecessary lines, and check what's in the current
directory
2023-10-17 18:02:40 -07:00
bucky 1f2e3d41dd syntax error extra - in there 2023-10-17 18:00:46 -07:00
bucky f31b6da49c include the .env file and remove the scret.rb file 2023-10-17 17:58:40 -07:00
bucky f32d153b69 simplified things? 2023-10-17 17:46:24 -07:00
bucky 15d9ade2cf remove EXPORT 2023-10-17 17:42:17 -07:00
bucky 4587c35806 just set it in the script 2023-10-17 17:40:23 -07:00
bucky 340614dadc echo outside catch error 2023-10-17 17:37:35 -07:00
bucky 8a0fef63b2 another try 2023-10-17 17:35:37 -07:00
bucky 8691d19e8d dump the zip file, let's see how it's working? 2023-10-17 17:32:50 -07:00
bucky 35d196bdc2 another shot accessing the new env var 2023-10-17 17:28:41 -07:00
bucky e2c3cb7035 access the ZIP_FILE variable properly? 2023-10-17 17:25:02 -07:00
bucky a69b3e4226 missed quote 2023-10-17 17:22:00 -07:00
bucky 36285b060b better try to set the environment 2023-10-17 17:19:31 -07:00
bucky a0a9e84b91 another try 2023-10-17 17:14:33 -07:00
bucky 01d9f9a21c another shot at setting the zip file name 2023-10-17 17:12:16 -07:00
bucky 621a777a46 update env vars
+ removed the app session secret. it's used where it is set
+ added zip file to make it easier to name the zip and reuse the name
2023-10-17 17:05:15 -07:00
bucky 6fbecd78a4 clean out unnecessary files a little easier 2023-10-17 10:39:17 -07:00
bucky 873b86a809 Merge pull request 'remove db files as well' (#25) from archive-deliverable into master
Reviewed-on: #25
2023-10-16 17:41:38 -07:00
bucky 47393a5ead remove db files as well 2023-10-16 17:30:11 -07:00
bucky 69c56ae31a Merge pull request 'archive-deliverable' (#24) from archive-deliverable into master
Reviewed-on: #24
2023-10-16 17:28:43 -07:00
bucky b2cdf60a32 Revert "simplify it a little"
This reverts commit 91f45965a0.
2023-10-16 17:23:50 -07:00
bucky 91f45965a0 simplify it a little 2023-10-16 17:18:06 -07:00
bucky 3097cb69aa clean the workspace when done 2023-10-16 17:04:23 -07:00
bucky eed17d61a3 use tmp as a staging place for building the tgz file 2023-10-16 16:35:56 -07:00
bucky 9e5a4069a4 wrapping all the commands in one script, hope it works? 2023-10-16 15:44:50 -07:00
bucky f8c20541d5 removed shopt, added that in jenkins user's .profile 2023-10-16 15:09:44 -07:00
bucky ee07312b86 another shot at getting local shell 2023-10-16 13:48:31 -07:00
bucky e4eabf8aa6 looking to see what shell is used 2023-10-16 12:06:11 -07:00
bucky 3ec0f0ff7b mkdir -p and wrapped the steps in a catch so the clean up happens 2023-10-16 12:01:10 -07:00
bucky 27b32fc8f4 another shot 2023-10-16 11:57:20 -07:00
bucky ceab408ec0 build deliverable, store it, and clean up afterwards 2023-10-16 10:54:52 -07:00
bucky b56b618a8c added stages to build a deliverable and then clean it up when done 2023-10-16 10:50:22 -07:00
4 changed files with 49 additions and 20 deletions
+2
View File
@@ -3,3 +3,5 @@
*.db *.db
.env.rb .env.rb
coverage coverage
vendor
.ruby-version
Vendored
+35 -10
View File
@@ -1,20 +1,17 @@
pipeline { pipeline {
agent any agent { label 'ruby && freebsd' }
environment { environment {
APP_SESSION_SECRET = ''
DB_NAME = 'url_shortener.db' DB_NAME = 'url_shortener.db'
} }
stages { stages {
stage('Init') { stage('Init') {
steps { steps {
sh 'rbenv local 3.2.2' sh ''' #!/usr/local/bin/bash
script { rbenv local 3.2.2
env.APP_SESSION_SECRET = sh(script: 'ruby secret.rb', returnStdout: true) echo "ENV[\\\"APP_SESSION_SECRET\\\"] ||= $(ruby -rsecurerandom -e 'puts SecureRandom.base64(64).inspect()')" > .env.rb
} echo "ENV[\\\"DB_NAME\\\"] ||= \\\"${DB_NAME}\\\"" >> .env.rb
sh 'echo "ENV[\\\"APP_SESSION_SECRET\\\"] ||= $(ruby secret.rb)" > .env.rb' '''
sh 'echo "ENV[\\\"DB_NAME\\\"] ||= \\\"${DB_NAME}\\\"" >> .env.rb'
sh 'cat .env.rb'
} }
} }
stage('Build dependencies') { stage('Build dependencies') {
@@ -35,7 +32,6 @@ pipeline {
} }
stage('Report results') { stage('Report results') {
steps { steps {
archive(includes: 'pkg/*.gem')
publishHTML (target: [ publishHTML (target: [
allowMissing: false, allowMissing: false,
alwaysLinkToLastBuild: false, alwaysLinkToLastBuild: false,
@@ -46,6 +42,32 @@ pipeline {
reportTitles: 'Cucumber Results, RSpec Results, Test Coverage']) reportTitles: 'Cucumber Results, RSpec Results, Test Coverage'])
} }
} }
stage('Build production deliverable') {
steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh ''' #!/usr/local/bin/bash
ZIP_FILE="url-shortener_${BRANCH_NAME}_$(date "+%Y-%m-%d_%H-%M-%S").tgz"
CUR_DIR=$(pwd)
mkdir -p /tmp/url-shortener
cp -R * /tmp/url-shortener
cp .env.rb /tmp/url-shortener/
cp .ruby-version /tmp/url-shortener/
cd /tmp/url-shortener
rm -rf features spec coverage db/*.db .git* Jenkinsfile *.html
cd /tmp
tar -czvf $ZIP_FILE url-shortener/
mv /tmp/$ZIP_FILE $CUR_DIR/
'''
}
archiveArtifacts artifacts: '*.tgz'
}
}
stage('Clean up deliverable') {
steps {
sh 'rm -rf /tmp/url-shortener'
sh 'rm -rf *.tgz'
}
}
} }
post { post {
success { success {
@@ -57,5 +79,8 @@ pipeline {
failure { failure {
mattermostSend channel: 'git-messages', color: 'danger', message: "[${JOB_NAME}](${JOB_URL}) [#${BUILD_NUMBER}](${BUILD_URL}) ([Gitea](${GIT_URL}))", text: "Build Failed" mattermostSend channel: 'git-messages', color: 'danger', message: "[${JOB_NAME}](${JOB_URL}) [#${BUILD_NUMBER}](${BUILD_URL}) ([Gitea](${GIT_URL}))", text: "Build Failed"
} }
always {
cleanWs deleteDirs: true, patterns: [[pattern: '*', type: 'INCLUDE']]
}
} }
} }
+12 -8
View File
@@ -1,11 +1,11 @@
# simple url shortener # simple url shortener
this project is a simple solution to build out a URL shortener using this project is a simple solution to build out a URL shortener using
Roda, Falcon, Sequel, and SQLite Roda, Puma, Sequel, and SQLite on a FreeBSD Jail
the point of this project is to quickly build something and work on continuous deployment while making small refinements to the functional pieces. the point of this project is to quickly build something and work on continuous deployment while making small refinements to the functional pieces.
the outside pieces of software that this project relies on are sqlite3 and pkgconf. the outside pieces of software that this project relies on are rbenv, ruby-build, sqlite3, and pkgconf.
@@ -14,9 +14,9 @@ first you have to install the dependencies:
`bundle install` `bundle install`
if you want the development group included run this first: if you want to skip the test dependencies:
`bundle config set --local with 'development'` `bundle config set --local without 'test'`
then create a .env.rb file in the root directory that contains the following ENV attributes: then create a .env.rb file in the root directory that contains the following ENV attributes:
@@ -24,15 +24,19 @@ then create a .env.rb file in the root directory that contains the following ENV
``` ```
ENV["APP_SESSION_SECRET"] = {output of a random 64 byte secret} ENV["APP_SESSION_SECRET"] = {output of a random 64 byte secret}
ENV["DB_NAME"] = {db file name} ENV["DB_NAME"] = {DB_NAME}
``` ```
after the dependencies are installed, you have to create the db after the dependencies are installed, you have to create the db and schema
`sequel -m db/migrations sqlite://db/{DB_NAME}` `sequel -m db/migrations sqlite://db/{DB_NAME}`
to start the application with Falcon: to start the application with Puma:
`rackup -o {ip address} -p {port} -s falcon` `rackup -o {ip address} -p {port}`
to run it as a daemon:
`rackup -o {ip address} -p {port} -D`
-2
View File
@@ -1,2 +0,0 @@
require 'securerandom'
puts SecureRandom.base64(64).inspect()