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
pull/26/head
Adam Townsend 2023-10-17 17:05:15 -07:00
parent 6fbecd78a4
commit 621a777a46
1 changed files with 8 additions and 8 deletions

16
Jenkinsfile vendored
View File

@ -2,16 +2,13 @@ pipeline {
agent any
environment {
APP_SESSION_SECRET = ''
DB_NAME = 'url_shortener.db'
ZIP_FILE = ''
}
stages {
stage('Init') {
steps {
sh 'rbenv local 3.2.2'
script {
env.APP_SESSION_SECRET = sh(script: 'ruby secret.rb', returnStdout: true)
}
sh 'echo "ENV[\\\"APP_SESSION_SECRET\\\"] ||= $(ruby secret.rb)" > .env.rb'
sh 'echo "ENV[\\\"DB_NAME\\\"] ||= \\\"${DB_NAME}\\\"" >> .env.rb'
sh 'cat .env.rb'
@ -47,6 +44,9 @@ pipeline {
}
stage('Build production deliverable') {
steps {
script {
env.ZIP_FILE="url-shortener_$(date "+%Y-%m-%d_%H-%M-%S").tgz"
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh ''' #!/usr/local/bin/bash
CUR_DIR=$(pwd)
@ -55,17 +55,17 @@ pipeline {
cd /tmp/url-shortener
rm -rf features spec coverage db/*.db .git* Jenkinsfile *.html
cd /tmp
tar -czvf url-shortener.tgz url-shortener/
mv url-shortener.tgz $CUR_DIR
tar -czvf $ZIP_FILE url-shortener/
mv /tmp/$ZIP_FILE $CUR_DIR/
'''
}
archiveArtifacts artifacts: 'url-shortener.tgz'
archiveArtifacts artifacts: '*.tgz'
}
}
stage('Clean up deliverable') {
steps {
sh 'rm -rf /tmp/url-shortener'
sh 'rm -rf url-shortener.tgz'
sh 'rm -rf $ZIP_FILE'
}
}
}