Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
5064c903
Commit
5064c903
authored
Oct 05, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix next bunch of tests
parent
782c8f9a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
10 deletions
+23
-10
app/models/ci/build.rb
app/models/ci/build.rb
+4
-0
app/services/ci/create_trigger_request_service.rb
app/services/ci/create_trigger_request_service.rb
+5
-2
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+4
-0
spec/requests/ci/api/triggers_spec.rb
spec/requests/ci/api/triggers_spec.rb
+10
-8
No files found.
app/models/ci/build.rb
View file @
5064c903
...
@@ -146,6 +146,10 @@ module Ci
...
@@ -146,6 +146,10 @@ module Ci
delegate
:sha
,
:short_sha
,
:project
,
delegate
:sha
,
:short_sha
,
:project
,
to: :commit
,
prefix:
false
to: :commit
,
prefix:
false
def
before_sha
Gitlab
::
Git
::
BLANK_SHA
end
def
trace_html
def
trace_html
html
=
Ci
::
Ansi2html
::
convert
(
trace
)
if
trace
.
present?
html
=
Ci
::
Ansi2html
::
convert
(
trace
)
if
trace
.
present?
html
||
''
html
||
''
...
...
app/services/ci/create_trigger_request_service.rb
View file @
5064c903
module
Ci
module
Ci
class
CreateTriggerRequestService
class
CreateTriggerRequestService
def
execute
(
project
,
trigger
,
ref
,
variables
=
nil
)
def
execute
(
project
,
trigger
,
ref
,
variables
=
nil
)
target
=
project
.
gl_project
.
repository
.
rev_parse_target
(
ref
)
return
unless
project
.
gl_project
return
unless
target
return
unless
project
.
gl_project
.
repository
# check if ref is tag
# check if ref is tag
target
=
project
.
gl_project
.
repository
.
rev_parse_target
(
ref
)
sha
=
target
.
oid
sha
=
target
.
oid
tag
=
target
.
is_a?
(
Rugged
::
Tag
)
||
target
.
is_a?
(
Rugged
::
Tag
::
Annotation
)
tag
=
target
.
is_a?
(
Rugged
::
Tag
)
||
target
.
is_a?
(
Rugged
::
Tag
::
Annotation
)
...
@@ -16,6 +17,8 @@ module Ci
...
@@ -16,6 +17,8 @@ module Ci
if
ci_commit
.
create_builds
(
ref
,
tag
,
nil
,
trigger_request
)
if
ci_commit
.
create_builds
(
ref
,
tag
,
nil
,
trigger_request
)
trigger_request
trigger_request
end
end
rescue
Rugged
::
OdbError
nil
end
end
end
end
end
end
spec/requests/ci/api/builds_spec.rb
View file @
5064c903
...
@@ -7,6 +7,10 @@ describe Ci::API::API do
...
@@ -7,6 +7,10 @@ describe Ci::API::API do
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let
(
:gl_project
)
{
FactoryGirl
.
create
(
:empty_project
,
gitlab_ci_project:
project
)
}
let
(
:gl_project
)
{
FactoryGirl
.
create
(
:empty_project
,
gitlab_ci_project:
project
)
}
before
do
stub_ci_commit_to_return_yaml_file
end
describe
"Builds API for runners"
do
describe
"Builds API for runners"
do
let
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
token:
"SharedRunner"
)
}
let
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
token:
"SharedRunner"
)
}
let
(
:shared_project
)
{
FactoryGirl
.
create
(
:ci_project
,
name:
"SharedProject"
)
}
let
(
:shared_project
)
{
FactoryGirl
.
create
(
:ci_project
,
name:
"SharedProject"
)
}
...
...
spec/requests/ci/api/triggers_spec.rb
View file @
5064c903
...
@@ -6,7 +6,7 @@ describe Ci::API::API do
...
@@ -6,7 +6,7 @@ describe Ci::API::API do
describe
'POST /projects/:project_id/refs/:ref/trigger'
do
describe
'POST /projects/:project_id/refs/:ref/trigger'
do
let!
(
:trigger_token
)
{
'secure token'
}
let!
(
:trigger_token
)
{
'secure token'
}
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:project
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:gl_project
)
{
FactoryGirl
.
create
(
:
empty_
project
,
gitlab_ci_project:
project
)
}
let!
(
:gl_project
)
{
FactoryGirl
.
create
(
:project
,
gitlab_ci_project:
project
)
}
let!
(
:project2
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:project2
)
{
FactoryGirl
.
create
(
:ci_project
)
}
let!
(
:trigger
)
{
FactoryGirl
.
create
(
:ci_trigger
,
project:
project
,
token:
trigger_token
)
}
let!
(
:trigger
)
{
FactoryGirl
.
create
(
:ci_trigger
,
project:
project
,
token:
trigger_token
)
}
let
(
:options
)
do
let
(
:options
)
do
...
@@ -15,6 +15,10 @@ describe Ci::API::API do
...
@@ -15,6 +15,10 @@ describe Ci::API::API do
}
}
end
end
before
do
stub_ci_commit_to_return_yaml_file
end
context
'Handles errors'
do
context
'Handles errors'
do
it
'should return bad request if token is missing'
do
it
'should return bad request if token is missing'
do
post
ci_api
(
"/projects/
#{
project
.
id
}
/refs/master/trigger"
)
post
ci_api
(
"/projects/
#{
project
.
id
}
/refs/master/trigger"
)
...
@@ -33,15 +37,13 @@ describe Ci::API::API do
...
@@ -33,15 +37,13 @@ describe Ci::API::API do
end
end
context
'Have a commit'
do
context
'Have a commit'
do
before
do
let
(
:commit
)
{
project
.
commits
.
last
}
@commit
=
FactoryGirl
.
create
(
:ci_commit
,
gl_project:
gl_project
)
end
it
'should create builds'
do
it
'should create builds'
do
post
ci_api
(
"/projects/
#{
project
.
id
}
/refs/master/trigger"
),
options
post
ci_api
(
"/projects/
#{
project
.
id
}
/refs/master/trigger"
),
options
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
@
commit
.
builds
.
reload
commit
.
builds
.
reload
expect
(
@
commit
.
builds
.
size
).
to
eq
(
2
)
expect
(
commit
.
builds
.
size
).
to
eq
(
2
)
end
end
it
'should return bad request with no builds created if there\'s no commit for that ref'
do
it
'should return bad request with no builds created if there\'s no commit for that ref'
do
...
@@ -70,8 +72,8 @@ describe Ci::API::API do
...
@@ -70,8 +72,8 @@ describe Ci::API::API do
it
'create trigger request with variables'
do
it
'create trigger request with variables'
do
post
ci_api
(
"/projects/
#{
project
.
id
}
/refs/master/trigger"
),
options
.
merge
(
variables:
variables
)
post
ci_api
(
"/projects/
#{
project
.
id
}
/refs/master/trigger"
),
options
.
merge
(
variables:
variables
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
@
commit
.
builds
.
reload
commit
.
builds
.
reload
expect
(
@
commit
.
builds
.
first
.
trigger_request
.
variables
).
to
eq
(
variables
)
expect
(
commit
.
builds
.
first
.
trigger_request
.
variables
).
to
eq
(
variables
)
end
end
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment