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
45e0e68f
Commit
45e0e68f
authored
Jun 15, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename jenkins service to jenkins integration
Renames project association to jenkins association name.
parent
3f8193f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
40 deletions
+47
-40
app/models/integration.rb
app/models/integration.rb
+1
-0
app/models/project.rb
app/models/project.rb
+1
-1
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-1
spec/models/integrations/jenkins_spec.rb
spec/models/integrations/jenkins_spec.rb
+44
-38
No files found.
app/models/integration.rb
View file @
45e0e68f
...
...
@@ -48,6 +48,7 @@ class Integration < ApplicationRecord
flowdock
hangouts_chat
irker
jenkins
packagist pipelines_email pivotaltracker pushover
mattermost mattermost_slash_commands microsoft_teams mock_ci mock_monitoring
]
.
to_set
.
freeze
...
...
app/models/project.rb
View file @
45e0e68f
...
...
@@ -172,7 +172,7 @@ class Project < ApplicationRecord
has_one
:flowdock_integration
,
class_name:
'Integrations::Flowdock'
has_one
:hangouts_chat_integration
,
class_name:
'Integrations::HangoutsChat'
has_one
:irker_integration
,
class_name:
'Integrations::Irker'
has_one
:jenkins_
service
,
class_name:
'Integrations::Jenkins'
has_one
:jenkins_
integration
,
class_name:
'Integrations::Jenkins'
has_one
:jira_service
,
class_name:
'Integrations::Jira'
has_one
:mattermost_integration
,
class_name:
'Integrations::Mattermost'
has_one
:mattermost_slash_commands_integration
,
class_name:
'Integrations::MattermostSlashCommands'
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
45e0e68f
...
...
@@ -485,7 +485,7 @@ project:
-
protected_environments
-
mirror_user
-
push_rule
-
jenkins_
service
-
jenkins_
integration
-
index_status
-
feature_usage
-
approval_rules
...
...
spec/models/integrations/jenkins_spec.rb
View file @
45e0e68f
...
...
@@ -30,8 +30,8 @@ RSpec.describe Integrations::Jenkins do
end
describe
'username validation'
do
before
do
@jenkins_service
=
described_class
.
create!
(
let
(
:jenkins_integration
)
do
described_class
.
create!
(
active:
active
,
project:
project
,
properties:
{
...
...
@@ -43,7 +43,7 @@ RSpec.describe Integrations::Jenkins do
)
end
subject
{
@jenkins_service
}
subject
{
jenkins_integration
}
context
'when the service is active'
do
let
(
:active
)
{
true
}
...
...
@@ -84,7 +84,7 @@ RSpec.describe Integrations::Jenkins do
describe
'#hook_url'
do
let
(
:username
)
{
nil
}
let
(
:password
)
{
nil
}
let
(
:jenkins_
service
)
do
let
(
:jenkins_
integration
)
do
described_class
.
new
(
project:
project
,
properties:
{
...
...
@@ -96,7 +96,7 @@ RSpec.describe Integrations::Jenkins do
)
end
subject
{
jenkins_
service
.
hook_url
}
subject
{
jenkins_
integration
.
hook_url
}
context
'when the jenkins_url has no relative path'
do
let
(
:jenkins_url
)
{
'http://jenkins.example.com/'
}
...
...
@@ -138,10 +138,10 @@ RSpec.describe Integrations::Jenkins do
user
=
create
(
:user
,
username:
'username'
)
project
=
create
(
:project
,
name:
'project'
)
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
jenkins_
service
=
described_class
.
create!
(
jenkins_params
)
jenkins_
integration
=
described_class
.
create!
(
jenkins_params
)
stub_request
(
:post
,
jenkins_hook_url
).
with
(
headers:
{
'Authorization'
=>
jenkins_authorization
})
result
=
jenkins_
service
.
test
(
push_sample_data
)
result
=
jenkins_
integration
.
test
(
push_sample_data
)
expect
(
result
).
to
eq
({
success:
true
,
result:
''
})
end
...
...
@@ -152,20 +152,20 @@ RSpec.describe Integrations::Jenkins do
let
(
:namespace
)
{
create
(
:group
,
:private
)
}
let
(
:project
)
{
create
(
:project
,
:private
,
name:
'project'
,
namespace:
namespace
)
}
let
(
:push_sample_data
)
{
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
}
let
(
:jenkins_
service
)
{
described_class
.
create!
(
jenkins_params
)
}
let
(
:jenkins_
integration
)
{
described_class
.
create!
(
jenkins_params
)
}
before
do
stub_request
(
:post
,
jenkins_hook_url
)
end
it
'invokes the Jenkins API'
do
jenkins_
service
.
execute
(
push_sample_data
)
jenkins_
integration
.
execute
(
push_sample_data
)
expect
(
a_request
(
:post
,
jenkins_hook_url
)).
to
have_been_made
.
once
end
it
'adds default web hook headers to the request'
do
jenkins_
service
.
execute
(
push_sample_data
)
jenkins_
integration
.
execute
(
push_sample_data
)
expect
(
a_request
(
:post
,
jenkins_hook_url
)
...
...
@@ -174,7 +174,7 @@ RSpec.describe Integrations::Jenkins do
end
it
'request url contains properly serialized username and password'
do
jenkins_
service
.
execute
(
push_sample_data
)
jenkins_
integration
.
execute
(
push_sample_data
)
expect
(
a_request
(
:post
,
'http://jenkins.example.com/project/my_project'
)
...
...
@@ -187,8 +187,8 @@ RSpec.describe Integrations::Jenkins do
let
(
:project
)
{
create
(
:project
)
}
context
'when a password was previously set'
do
before
do
@jenkins_service
=
described_class
.
create!
(
let
(
:jenkins_integration
)
do
described_class
.
create!
(
project:
project
,
properties:
{
jenkins_url:
'http://jenkins.example.com/'
,
...
...
@@ -199,42 +199,47 @@ RSpec.describe Integrations::Jenkins do
end
it
'resets password if url changed'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins-edited.example.com/'
@jenkins_service
.
save!
expect
(
@jenkins_service
.
password
).
to
be_nil
jenkins_integration
.
jenkins_url
=
'http://jenkins-edited.example.com/'
jenkins_integration
.
save!
expect
(
jenkins_integration
.
password
).
to
be_nil
end
it
'resets password if username is blank'
do
@jenkins_service
.
username
=
''
@jenkins_service
.
save!
expect
(
@jenkins_service
.
password
).
to
be_nil
jenkins_integration
.
username
=
''
jenkins_integration
.
save!
expect
(
jenkins_integration
.
password
).
to
be_nil
end
it
'does not reset password if username changed'
do
@jenkins_service
.
username
=
'some_name'
@jenkins_service
.
save!
expect
(
@jenkins_service
.
password
).
to
eq
(
'password'
)
jenkins_integration
.
username
=
'some_name'
jenkins_integration
.
save!
expect
(
jenkins_integration
.
password
).
to
eq
(
'password'
)
end
it
'does not reset password if new url is set together with password, even if it\'s the same password'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins_edited.example.com/'
@jenkins_service
.
password
=
'password'
@jenkins_service
.
save!
expect
(
@jenkins_service
.
password
).
to
eq
(
'password'
)
expect
(
@jenkins_service
.
jenkins_url
).
to
eq
(
'http://jenkins_edited.example.com/'
)
jenkins_integration
.
jenkins_url
=
'http://jenkins_edited.example.com/'
jenkins_integration
.
password
=
'password'
jenkins_integration
.
save!
expect
(
jenkins_integration
.
password
).
to
eq
(
'password'
)
expect
(
jenkins_integration
.
jenkins_url
).
to
eq
(
'http://jenkins_edited.example.com/'
)
end
it
'resets password if url changed, even if setter called multiple times'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins1.example.com/'
@jenkins_service
.
jenkins_url
=
'http://jenkins1.example.com/'
@jenkins_service
.
save!
expect
(
@jenkins_service
.
password
).
to
be_nil
jenkins_integration
.
jenkins_url
=
'http://jenkins1.example.com/'
jenkins_integration
.
jenkins_url
=
'http://jenkins1.example.com/'
jenkins_integration
.
save!
expect
(
jenkins_integration
.
password
).
to
be_nil
end
end
context
'when no password was previously set'
do
before
do
@jenkins_service
=
described_class
.
create!
(
let
(
:jenkins_integration
)
do
described_class
.
create!
(
project:
create
(
:project
),
properties:
{
jenkins_url:
'http://jenkins.example.com/'
,
...
...
@@ -244,11 +249,12 @@ RSpec.describe Integrations::Jenkins do
end
it
'saves password if new url is set together with password'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins_edited.example.com/'
@jenkins_service
.
password
=
'password'
@jenkins_service
.
save!
expect
(
@jenkins_service
.
password
).
to
eq
(
'password'
)
expect
(
@jenkins_service
.
jenkins_url
).
to
eq
(
'http://jenkins_edited.example.com/'
)
jenkins_integration
.
jenkins_url
=
'http://jenkins_edited.example.com/'
jenkins_integration
.
password
=
'password'
jenkins_integration
.
save!
expect
(
jenkins_integration
.
password
).
to
eq
(
'password'
)
expect
(
jenkins_integration
.
jenkins_url
).
to
eq
(
'http://jenkins_edited.example.com/'
)
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