class JenkinsGenerator

Public Instance Methods

create_jenkins_file() click to toggle source
# File lib/generators/jenkins/jenkins_generator.rb, line 5
  def create_jenkins_file
    brakeman = 'echo "Checking securtiy issues with brakeman"
bundle exec gergich capture brakeman "bundle exec brakeman --quiet --format json --exit-on-warn"
EXIT_CODES=$(($EXIT_CODES + $?))
' if features.include?('brakeman')
    puts features.include?('brakeman')

    rubocop = 'echo "Analyzing ruby code with rubocop"
bundle exec gergich capture rubocop "bundle exec rubocop --fail-level autocorrect"
EXIT_CODES=$(($EXIT_CODES + $?))
' if features.include?('rubocop')

    eslint = 'echo "Analyzing js with eslint"
bundle exec gergich capture eslint "bundle exec rake eslint:run[app]"
EXIT_CODES=$(($EXIT_CODES + $?))
' if features.include?('eslint')

    create_file "bin/jenkins",
"#!/usr/bin/env bash

set +e
EXIT_CODES=0

# Allow time for postgres to start
for i in {1..6}; do
  bundle exec rake db:create && break
  test $i -eq 6 && echo 'Failed to db:create' && exit 1
  sleep 1
done

bundle exec rake db:migrate

echo 'Checking last migration is reversible'
bundle exec rake db:migrate:redo
EXIT_CODES=$(($EXIT_CODES + $?))

#{[brakeman, rubocop, eslint].compact.join("\n")}
echo 'Running ruby specs'
bundle exec rspec
EXIT_CODES=$(($EXIT_CODES + $?))

echo 'Running JS specs...'
npm run test
EXIT_CODES=$(($EXIT_CODES + $?))

bundle exec gergich publish
exit $EXIT_CODES"

    inside Rails.root do
      run "chmod +rwx bin/jenkins"
    end
  end