From fbd056f49570fbe2b7c8dfb47138f7069eeae0af Mon Sep 17 00:00:00 2001 From: Mark Vanderwiel Date: Thu, 4 Sep 2014 10:32:16 -0500 Subject: [PATCH] Fix chef gates, allow sudo for gem install and use ruby 1.9.1 * We need to install system gecode 3.x libraries which requires sudo. move revoke sudo step to below the bundler-prep step to allow that. * We need to use ruby 1.9.1. A previous commit removed the ruby1.9.1 prefix (see bug) * Cleanup repo to use common builders Change-Id: I7622cd939a26c29712d89dded8d2657ce25f3a82 Closes-Bug: #1357439 --- .../jenkins_job_builder/config/chef-jobs.yaml | 17 ++++++-------- .../jenkins_job_builder/config/macros.yaml | 23 +++++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/openstack_project/files/jenkins_job_builder/config/chef-jobs.yaml b/modules/openstack_project/files/jenkins_job_builder/config/chef-jobs.yaml index 46cae69371..c1b3e6bbc5 100644 --- a/modules/openstack_project/files/jenkins_job_builder/config/chef-jobs.yaml +++ b/modules/openstack_project/files/jenkins_job_builder/config/chef-jobs.yaml @@ -8,9 +8,9 @@ - timestamps builders: - - revoke-sudo - gerrit-git-prep - chef-bundler-prep + - revoke-sudo - chef-berkshelf-prep - chef-cookbook-chefspec @@ -27,9 +27,9 @@ - timestamps builders: - - revoke-sudo - gerrit-git-prep - chef-bundler-prep + - revoke-sudo - chef-berkshelf-prep - chef-cookbook-foodcritic @@ -46,9 +46,9 @@ - timestamps builders: - - revoke-sudo - gerrit-git-prep - chef-bundler-prep + - revoke-sudo - chef-berkshelf-prep - chef-cookbook-rubocop @@ -60,17 +60,14 @@ node: 'bare-precise || bare-trusty' builders: - - revoke-sudo - gerrit-git-prep + - chef-bundler-prep + - revoke-sudo + - chef-berkshelf-prep - shell: | #!/bin/bash -xe - mkdir -p .cookbooks .bundle - bundle config --global jobs $(nproc) - bundle install --path=.bundle - # Validates cookbooks - bundle exec berks install --path=.cookbooks # Validates roles - bundle exec spiceweasel infrastructure.yml --debug + ruby1.9.1 `which bundle` exec spiceweasel infrastructure.yml --debug publishers: - console-log diff --git a/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml b/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml index a053fdcfff..d680b9658c 100644 --- a/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml +++ b/modules/openstack_project/files/jenkins_job_builder/config/macros.yaml @@ -133,9 +133,9 @@ if [ $? -eq 0 ]; then # For Berkshelf 3.x use the system gecode 3.x libraries sudo apt-get install -y libgecode-dev - USE_SYSTEM_GECODE=1 bundle install --path=.bundle --jobs 1 --retry 3 --verbose + USE_SYSTEM_GECODE=1 ruby1.9.1 `which bundle` install --path=.bundle --jobs 1 --retry 3 --verbose else - bundle install --path=.bundle --jobs 1 --retry 3 --verbose + ruby1.9.1 `which bundle` install --path=.bundle --jobs 1 --retry 3 --verbose fi - builder: @@ -145,10 +145,10 @@ #!/bin/bash -x grep -E .*berkshelf.*3\.\d*\.\d*.* Gemfile if [ $? -eq 0 ]; then - bundle exec berks vendor .cookbooks + ruby1.9.1 `which bundle` exec berks vendor .cookbooks else mkdir -p .cookbooks - bundle exec berks install --path=.cookbooks + ruby1.9.1 `which bundle` exec berks install --path=.cookbooks fi COOKBOOK=$(awk '/^name/ {print $NF}' metadata.rb |tr -d \"\') if [ -z $COOKBOOK ]; then @@ -160,31 +160,34 @@ name: chef-cookbook-rubocop builders: - shell: | + #!/bin/bash -x if grep rubocop: Strainerfile; then - bundle exec strainer test --cookbooks-path=.cookbooks --only=rubocop + ruby1.9.1 `which bundle` exec strainer test --cookbooks-path=.cookbooks --only=rubocop else - bundle exec rubocop + ruby1.9.1 `which bundle` exec rubocop fi - builder: name: chef-cookbook-foodcritic builders: - shell: | + #!/bin/bash -x if grep foodcritic: Strainerfile; then - bundle exec strainer test --cookbooks-path=.cookbooks --only=foodcritic + ruby1.9.1 `which bundle` exec strainer test --cookbooks-path=.cookbooks --only=foodcritic else - bundle exec foodcritic -f any -t ~FC003 -t ~FC023 . + ruby1.9.1 `which bundle` exec foodcritic -f any -t ~FC003 -t ~FC023 . fi - builder: name: chef-cookbook-chefspec builders: - shell: | + #!/bin/bash -x COOKBOOK=$(awk '/^name/ {print $NF}' metadata.rb |tr -d \"\') if grep chefspec: Strainerfile; then - bundle exec strainer test --cookbooks-path=.cookbooks --only=chefspec + ruby1.9.1 `which bundle` exec strainer test --cookbooks-path=.cookbooks --only=chefspec else - bundle exec rspec .cookbooks/$COOKBOOK/spec + ruby1.9.1 `which bundle` exec rspec .cookbooks/$COOKBOOK/spec fi - builder: