From 35b795632b34056131aef8b4da85447db566e733 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Sat, 6 Jan 2018 13:41:25 -0800 Subject: [PATCH] Improve jenkins build and potential to publish --- .env.sh | 6 ++++++ Jenkinsfile | 29 ++++++++++++++++++++--------- lib/puppet_x/ldapquery.rb | 2 ++ 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 .env.sh diff --git a/.env.sh b/.env.sh new file mode 100644 index 0000000..5a1da7c --- /dev/null +++ b/.env.sh @@ -0,0 +1,6 @@ +#! /bin/bash + +if [ -x ~/.rbenv/bin/rbenv ]; then + export PATH="$HOME/.rbenv/bin:$PATH" + eval "$(~/.rbenv/bin/rbenv init -)" +fi diff --git a/Jenkinsfile b/Jenkinsfile index 48ae9db..51532f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,20 +1,31 @@ pipeline { agent any + + triggers { pollSCM('*/15 * * * *') } + + environment { + PATH = "$PATH:~/.rbenv/bin" + } + stages { - stage('bundle') { + stage('test') { steps { - sh 'bundle' + sh '. .env.sh && printenv && bundle' + sh '. .env.sh && bundle exec rake test' } } - stage('rake test') { - steps { - sh 'bundle exec rake test' + + stage('build') { + when { + branch 'master' } - } - stage('module:build') { + steps { - sh 'bundle exec rake module:build' + sh '. .env.sh && bundle exec rake clean' + sh '. .env.sh && bundle exec rake build' + + sh '[ "$(git rev-list -n 1 $(git tag | tail -n 1 ))" == "$(git rev-list -n 1 HEAD)" ] && bundle exec rake publish pkg/*.tar.gz' } } } -} \ No newline at end of file +} diff --git a/lib/puppet_x/ldapquery.rb b/lib/puppet_x/ldapquery.rb index c639bdf..21062d5 100644 --- a/lib/puppet_x/ldapquery.rb +++ b/lib/puppet_x/ldapquery.rb @@ -52,6 +52,8 @@ module PuppetX tls = Puppet[:ldaptls] ca_file = "#{Puppet[:confdir]}/ldap_ca.pem" + # TODO if not exists ldap_ca.pem fail + conf = { host: host, port: port