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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a8c12e95
Commit
a8c12e95
authored
Feb 23, 2018
by
James Edwards-Jones
Committed by
Douwe Maan
Mar 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CI/CD GitHub import sets up service integration
Sets up service to notify GitHub of pipeline status
parent
3da6d69a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
0 deletions
+104
-0
ee/app/services/ci_cd/github_integration_setup_service.rb
ee/app/services/ci_cd/github_integration_setup_service.rb
+55
-0
ee/app/services/ci_cd/github_setup_service.rb
ee/app/services/ci_cd/github_setup_service.rb
+5
-0
ee/changelogs/unreleased/jej-ci-cd-only-sets-up-github-service-integration.yml
...sed/jej-ci-cd-only-sets-up-github-service-integration.yml
+5
-0
ee/spec/services/ci_cd/github_integration_setup_service_spec.rb
...c/services/ci_cd/github_integration_setup_service_spec.rb
+31
-0
ee/spec/services/ci_cd/github_setup_service_spec.rb
ee/spec/services/ci_cd/github_setup_service_spec.rb
+8
-0
No files found.
ee/app/services/ci_cd/github_integration_setup_service.rb
0 → 100644
View file @
a8c12e95
module
CiCd
class
GithubIntegrationSetupService
attr_reader
:project
def
initialize
(
project
)
@project
=
project
end
def
execute
github_integration
.
save
end
private
def
github_integration
@github_integration
||=
project
.
build_github_service
(
github_params
)
end
def
github_params
GithubParams
.
new
(
project
).
configuration_params
end
class
GithubParams
def
initialize
(
project
)
@project
=
project
end
def
repository_url
"
#{
import_uri
.
scheme
}
://
#{
import_uri
.
host
}
/
#{
repo_full_name
}
"
end
def
configuration_params
{
active:
true
,
repository_url:
repository_url
,
token:
github_access_token
}
end
private
def
github_access_token
@project
.
import_data
&
.
credentials
&
.
dig
(
:user
)
end
def
repo_full_name
@project
.
import_source
end
def
import_uri
URI
.
parse
(
@project
.
import_url
)
end
end
end
end
ee/app/services/ci_cd/github_setup_service.rb
View file @
a8c12e95
...
@@ -8,6 +8,7 @@ module CiCd
...
@@ -8,6 +8,7 @@ module CiCd
def
execute
def
execute
create_webhook
create_webhook
setup_project_integration
end
end
private
private
...
@@ -15,5 +16,9 @@ module CiCd
...
@@ -15,5 +16,9 @@ module CiCd
def
create_webhook
def
create_webhook
::
CreateGithubWebhookWorker
.
perform_async
(
project
.
id
)
::
CreateGithubWebhookWorker
.
perform_async
(
project
.
id
)
end
end
def
setup_project_integration
::
CiCd
::
GithubIntegrationSetupService
.
new
(
project
).
execute
end
end
end
end
end
ee/changelogs/unreleased/jej-ci-cd-only-sets-up-github-service-integration.yml
0 → 100644
View file @
a8c12e95
---
title
:
GitHub CI/CD import sets up pipeline notification integration
merge_request
:
4687
author
:
type
:
added
ee/spec/services/ci_cd/github_integration_setup_service_spec.rb
0 → 100644
View file @
a8c12e95
require
'spec_helper'
describe
CiCd
::
GithubIntegrationSetupService
do
let
(
:repo_full_name
)
{
"MyUser/my-project"
}
let
(
:api_token
)
{
"abcdefghijk123"
}
let
(
:import_url
)
{
"https://
#{
api_token
}
@github.com/
#{
repo_full_name
}
.git"
}
let
(
:credentials
)
{
{
user:
api_token
}
}
let
(
:project
)
do
create
(
:project
,
import_source:
repo_full_name
,
import_url:
import_url
,
import_data_attributes:
{
credentials:
credentials
}
)
end
subject
{
described_class
.
new
(
project
)
}
before
do
subject
.
execute
end
describe
'sets up GitHub service integration'
do
let
(
:integration
)
{
project
.
github_service
}
specify
'with API token'
do
expect
(
integration
.
token
).
to
eq
api_token
end
specify
'with repo URL'
do
expect
(
integration
.
repository_url
).
to
eq
'https://github.com/MyUser/my-project'
end
end
end
ee/spec/services/ci_cd/github_setup_service_spec.rb
View file @
a8c12e95
...
@@ -13,5 +13,13 @@ describe CiCd::GithubSetupService do
...
@@ -13,5 +13,13 @@ describe CiCd::GithubSetupService do
subject
.
execute
subject
.
execute
end
end
it
'sets up GithubService project integration'
do
allow
(
subject
).
to
receive
(
:create_webhook
)
subject
.
execute
expect
(
project
.
github_service
).
to
be_active
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