5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# 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
|