Skip to content

Commit 76408e8

Browse files
author
Stanislav Kolotinskiy
committed
Exit on Coverity scan failure
1 parent 5f10098 commit 76408e8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/travis/build/addons/coverity_scan.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def build_command
8080
env << "COVERITY_SCAN_BUILD_COMMAND_PREPEND=\"${COVERITY_SCAN_BUILD_COMMAND_PREPEND:-#{@config[:build_command_prepend]}}\""
8181
env << "COVERITY_SCAN_BRANCH_PATTERN=${COVERITY_SCAN_BRANCH_PATTERN:-#{@config[:branch_pattern]}}"
8282
sh.cmd "curl -s #{@config[:build_script_url]} | #{env.join(' ')} bash", echo: true
83+
sh.raw 'result=$?', echo: true
84+
sh.if '$result -ne 0', echo: true do
85+
sh.raw "echo -e \"\033[33;1mSkipping build_coverity due to script error\033[0m\""
86+
sh.raw 'exit 1', echo: true
87+
end
8388
end
8489
end
8590
sh.else echo:true do

spec/build/addons/coverity_scan_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe Travis::Build::Addons::CoverityScan, :sexp do
44
let(:script) { stub('script') }
5-
let(:config) { {} }
5+
let(:config) { { project: { name: 'test' } } }
66
let(:data) { payload_for(:push, :ruby, config: { addons: { coverity_scan: config } }) }
77
let(:sh) { Travis::Shell::Builder.new }
88
let(:addon) { described_class.new(script, sh, Travis::Build::Data.new(data), config) }
@@ -13,5 +13,7 @@
1313
# let(:code) { ['CODECLIMATE_REPO_TOKEN=1234'] }
1414
# end
1515

16-
xit 'needs specs!'
16+
it 'returns some lines' do
17+
expect(subject).to be_present
18+
end
1719
end

0 commit comments

Comments
 (0)