url-shortener/Jenkinsfile

47 lines
1.4 KiB
Groovy

pipeline {
agent any
environment {
APP_SESSION_SECRET = ''
DB_NAME = 'url_shortener.db'
}
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'
}
}
stage('Build dependencies') {
steps {
sh 'bundle install'
sh 'sequel -m db/migrations sqlite://db/${DB_NAME}'
}
}
stage('Run tests') {
steps {
sh 'cucumber features --format html --out coverage/cucumber.html'
}
}
stage('Report results') {
steps {
archive(includes: 'pkg/*.gem')
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'coverage',
reportFiles: 'cucumber.html, index.html',
reportName: 'Test Results',
reportTitles: 'Cucumber Results, Test Coverage'])
mattermostSend channel: 'git-messages', color: 'good', message: "[${JOB_NAME}](${JOB_URL}) [#${BUILD_NUMBER}](${BUILD_URL}) ([Gitea](${GIT_URL})) ${GIT_COMMIT}", text: 'Build Finished Successfully', icon: 'https://jenkins.dev.desnudopenguino.com/static/be5e4e89/apple-touch-icon.png'
}
}
}
}