Skip to content

Instantly share code, notes, and snippets.

@wshihadeh
Last active December 4, 2019 15:29
Show Gist options
  • Save wshihadeh/a91b6b5c4ab57f2c67f39b8ffa318aac to your computer and use it in GitHub Desktop.
Save wshihadeh/a91b6b5c4ab57f2c67f39b8ffa318aac to your computer and use it in GitHub Desktop.
Orca Jenkins file
pipeline {
/* specify nodes for executing */
agent {
label 'ci-deployment'
}
/* log rotation */
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
}
/* variables */
parameters {
string(name: 'REPO', defaultValue: 'git@github.com:wshihadeh/test_orca.git', description: "Orca repo")
string(name: 'BRANCH', defaultValue: 'develop', description: "Orca branch")
string(name: 'DEPLOYED_STACKS', defaultValue: 'changeme', description: "List of apps to be deployed. Choose from: nginx mysql simple_rails")
string(name: 'SIMPLE_RAILS_IMAGE_TAG', defaultValue: 'latest', description: "Docker image tag to deploy simple_rails")
choice(
name: 'SANDBOX',
choices: 'production\nstage\ntest',
description: 'Which sandbox?'
)
}
stages {
/* checkout orca repo */
stage('Checkout SCM') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '${BRANCH}']],
userRemoteConfigs: [[
url: '${REPO}',
credentialsId: '',
]]
])
echo ">> Run deploy applications ${DEPLOYED_STACKS}"
}
}
/* precondition step */
stage('Precondition Step') {
steps {
script {
env.RUBY_VERSION = readFile('.ruby-version').trim()
env.GEMSET_VERSION = readFile('.ruby-gemset').trim()
}
echo ">> RUBY_VERSION is ${RUBY_VERSION}"
echo ">> GEMSET_VERSION is ${GEMSET_VERSION}"
}
}
/* Deploy applications on integration testing environment */
stage('Deploy applications on integration testing environment') {
steps {
sh '''#!/bin/bash -le
cd capistrano
rvm use ruby-${RUBY_VERSION} --install
rvm gemset use --create ruby-${RUBY_VERSION}@${GEMSET_VERSION}
gem install bundler
bundle install
DEPLOYED_STACKS=$DEPLOYED_STACKS bundle exec cap $SANDBOX deploy:auto
'''
}
}
}
/* Cleanup workspace */
post {
always {
deleteDir()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment