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
7e375506
Commit
7e375506
authored
Apr 09, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
055ae8bf
87f665e8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
29 deletions
+103
-29
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+8
-2
changelogs/unreleased/prevent-running-mr-pipelines-when-target-updated.yml
...ased/prevent-running-mr-pipelines-when-target-updated.yml
+5
-0
doc/ci/docker/using_docker_build.md
doc/ci/docker/using_docker_build.md
+18
-17
doc/development/fe_guide/vue.md
doc/development/fe_guide/vue.md
+3
-3
lib/gitlab/ci/config/entry/environment.rb
lib/gitlab/ci/config/entry/environment.rb
+2
-0
spec/lib/gitlab/ci/config/entry/environment_spec.rb
spec/lib/gitlab/ci/config/entry/environment_spec.rb
+40
-0
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+27
-7
No files found.
app/services/merge_requests/refresh_service.rb
View file @
7e375506
...
...
@@ -21,6 +21,7 @@ module MergeRequests
post_merge_manually_merged
reload_merge_requests
outdate_suggestions
refresh_pipelines_on_merge_requests
reset_merge_when_pipeline_succeeds
mark_pending_todos_done
cache_merge_requests_closing_issues
...
...
@@ -107,8 +108,6 @@ module MergeRequests
end
merge_request
.
mark_as_unchecked
create_pipeline_for
(
merge_request
,
current_user
)
UpdateHeadPipelineForMergeRequestWorker
.
perform_async
(
merge_request
.
id
)
end
# Upcoming method calls need the refreshed version of
...
...
@@ -134,6 +133,13 @@ module MergeRequests
end
end
def
refresh_pipelines_on_merge_requests
merge_requests_for_source_branch
.
each
do
|
merge_request
|
create_pipeline_for
(
merge_request
,
current_user
)
UpdateHeadPipelineForMergeRequestWorker
.
perform_async
(
merge_request
.
id
)
end
end
def
reset_merge_when_pipeline_succeeds
merge_requests_for_source_branch
.
each
(
&
:reset_merge_when_pipeline_succeeds
)
end
...
...
changelogs/unreleased/prevent-running-mr-pipelines-when-target-updated.yml
0 → 100644
View file @
7e375506
---
title
:
Create pipelines for merge requests only when source branch is updated
merge_request
:
26921
author
:
type
:
fixed
doc/ci/docker/using_docker_build.md
View file @
7e375506
...
...
@@ -303,20 +303,19 @@ services:
-
docker:dind
variables
:
CONTAINER_IMAGE
:
registry.gitlab.com/$CI_PROJECT_PATH
DOCKER_HOST
:
tcp://docker:2375
DOCKER_DRIVER
:
overlay2
before_script
:
-
docker login -u
gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
-
docker login -u
$CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build
:
stage
:
build
script
:
-
docker pull $C
ONTAINER
_IMAGE:latest ||
true
-
docker build --cache-from $C
ONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_SHA --tag $CONTAINER
_IMAGE:latest .
-
docker push $C
ONTAINER
_IMAGE:$CI_COMMIT_SHA
-
docker push $C
ONTAINER
_IMAGE:latest
-
docker pull $C
I_REGISTRY
_IMAGE:latest ||
true
-
docker build --cache-from $C
I_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY
_IMAGE:latest .
-
docker push $C
I_REGISTRY
_IMAGE:$CI_COMMIT_SHA
-
docker push $C
I_REGISTRY
_IMAGE:latest
```
The steps in the
`script`
section for the
`build`
stage can be summed up to:
...
...
@@ -324,7 +323,7 @@ The steps in the `script` section for the `build` stage can be summed up to:
1.
The first command tries to pull the image from the registry so that it can be
used as a cache for the
`docker build`
command.
1.
The second command builds a Docker image using the pulled image as a
cache (notice the
`--cache-from $C
ONTAINER
_IMAGE:latest`
argument) if
cache (notice the
`--cache-from $C
I_REGISTRY
_IMAGE:latest`
argument) if
available, and tags it.
1.
The last two commands push the tagged Docker images to the container registry
so that they may also be used as cache for subsequent builds.
...
...
@@ -421,14 +420,14 @@ and depend on the visibility of your project.
For all projects, mostly suitable for public ones:
-
**Using the special `
gitlab-ci-token` user**
: This user
is created for you in order to
-
**Using the special `
$CI_REGISTRY_USER` variable**
: The user specified by this variable
is created for you in order to
push to the Registry connected to your project. Its password is automatically
set with the
`$CI_
JOB_TOKEN
`
variable. This allows you to automate building and deploying
set with the
`$CI_
REGISTRY_PASSWORD
`
variable. This allows you to automate building and deploying
your Docker images and has read/write access to the Registry. This is ephemeral,
so it's only valid for one job. You can use the following example as-is:
```sh
docker login -u
gitlab-ci-token -p $CI_JOB_TOKEN
$CI_REGISTRY
docker login -u
$CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
$CI_REGISTRY
```
For private and internal projects:
...
...
@@ -436,8 +435,10 @@ For private and internal projects:
-
**Using a personal access token**
: You can create and use a
[
personal access token
](
../../user/profile/personal_access_tokens.md
)
in case your project is private:
-
For read (pull) access, the scope should be
`read_registry`
.
-
For read/write (pull/push) access, use
`api`
.
-
For read (pull) access, the scope should be
`read_registry`
.
-
For read/write (pull/push) access, use
`api`
.
Replace the
`<username>`
and
`<access_token>`
in the following example:
```sh
...
...
@@ -469,9 +470,9 @@ could look like:
DOCKER_DRIVER
:
overlay2
stage
:
build
script
:
-
docker login -u
gitlab-ci-token -p $CI_JOB_TOKEN registry.example.com
-
docker build -t
registry.example.com
/group/project/image:latest .
-
docker push
registry.example.com
/group/project/image:latest
-
docker login -u
$CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-
docker build -t
$CI_REGISTRY
/group/project/image:latest .
-
docker push
$CI_REGISTRY
/group/project/image:latest
```
You can also make use of
[
other variables
](
../variables/README.md
)
to avoid hardcoding:
...
...
@@ -486,7 +487,7 @@ variables:
IMAGE_TAG
:
$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
before_script
:
-
docker login -u
gitlab-ci-token -p $CI_JOB_TOKEN
$CI_REGISTRY
-
docker login -u
$CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
$CI_REGISTRY
build
:
stage
:
build
...
...
@@ -526,7 +527,7 @@ variables:
CONTAINER_RELEASE_IMAGE
:
$CI_REGISTRY_IMAGE:latest
before_script
:
-
docker login -u
gitlab-ci-token -p $CI_JOB_TOKEN
$CI_REGISTRY
-
docker login -u
$CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
$CI_REGISTRY
build
:
stage
:
build
...
...
doc/development/fe_guide/vue.md
View file @
7e375506
...
...
@@ -38,7 +38,7 @@ _For consistency purposes, we recommend you to follow the same structure._
Let's look into each of them:
### A `index.js` file
### A
n
`index.js` file
This is the index file of your new feature. This is where the root Vue instance
of the new feature should be.
...
...
@@ -46,7 +46,7 @@ of the new feature should be.
The Store and the Service should be imported and initialized in this file and
provided as a prop to the main component.
Don't forget to follow
[
these steps
][
page_specific_javascript
]
.
Be sure to read about
[
page-specific JavaScript
][
page_specific_javascript
]
.
### Bootstrapping Gotchas
#### Providing data from HAML to JavaScript
...
...
@@ -240,7 +240,7 @@ One should apply to be a Vue.js expert by opening an MR when the Merge Request's
[
vue-docs
]:
http://vuejs.org/guide/index.html
[
issue-boards
]:
https://gitlab.com/gitlab-org/gitlab-ce/tree/master/app/assets/javascripts/boards
[
environments-table
]:
https://gitlab.com/gitlab-org/gitlab-ce/tree/master/app/assets/javascripts/environments
[
page_specific_javascript
]:
https://docs.gitlab.com/ce/development/frontend.html
#page-specific-javascript
[
page_specific_javascript
]:
./performance.md
#page-specific-javascript
[
component-system
]:
https://vuejs.org/v2/guide/#Composing-with-Components
[
state-management
]:
https://vuejs.org/v2/guide/state-management.html#Simple-State-Management-from-Scratch
[
one-way-data-flow
]:
https://vuejs.org/v2/guide/components.html#One-Way-Data-Flow
...
...
lib/gitlab/ci/config/entry/environment.rb
View file @
7e375506
...
...
@@ -36,10 +36,12 @@ module Gitlab
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:url
,
type:
String
,
length:
{
maximum:
255
},
allow_nil:
true
validates
:action
,
type:
String
,
inclusion:
{
in:
%w[start stop]
,
message:
'should be start or stop'
},
allow_nil:
true
...
...
spec/lib/gitlab/ci/config/entry/environment_spec.rb
View file @
7e375506
...
...
@@ -100,6 +100,26 @@ describe Gitlab::Ci::Config::Entry::Environment do
end
end
context
'when wrong action type is used'
do
let
(
:config
)
do
{
name:
'production'
,
action:
[
'stop'
]
}
end
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
describe
'#errors'
do
it
'contains error about wrong action type'
do
expect
(
entry
.
errors
)
.
to
include
'environment action should be a string'
end
end
end
context
'when invalid action is used'
do
let
(
:config
)
do
{
name:
'production'
,
...
...
@@ -151,6 +171,26 @@ describe Gitlab::Ci::Config::Entry::Environment do
end
end
context
'when wrong url type is used'
do
let
(
:config
)
do
{
name:
'production'
,
url:
[
'https://meow.meow'
]
}
end
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
describe
'#errors'
do
it
'contains error about wrong url type'
do
expect
(
entry
.
errors
)
.
to
include
'environment url should be a string'
end
end
end
context
'when variables are used for environment'
do
let
(
:config
)
do
{
name:
'review/$CI_COMMIT_REF_NAME'
,
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
7e375506
...
...
@@ -152,7 +152,10 @@ describe MergeRequests::RefreshService do
stub_ci_pipeline_yaml_file
(
YAML
.
dump
(
config
))
end
subject
{
service
.
new
(
@project
,
@user
).
execute
(
@oldrev
,
@newrev
,
'refs/heads/master'
)
}
subject
{
service
.
new
(
project
,
@user
).
execute
(
@oldrev
,
@newrev
,
ref
)
}
let
(
:ref
)
{
'refs/heads/master'
}
let
(
:project
)
{
@project
}
context
"when .gitlab-ci.yml has merge_requests keywords"
do
let
(
:config
)
do
...
...
@@ -168,14 +171,17 @@ describe MergeRequests::RefreshService do
it
'create detached merge request pipeline with commits'
do
expect
{
subject
}
.
to
change
{
@merge_request
.
merge_request_pipelines
.
count
}.
by
(
1
)
.
and
change
{
@fork_merge_request
.
merge_request_pipelines
.
count
}.
by
(
1
)
.
and
change
{
@another_merge_request
.
merge_request_pipelines
.
count
}.
by
(
0
)
expect
(
@merge_request
.
has_commits?
).
to
be_truthy
expect
(
@fork_merge_request
.
has_commits?
).
to
be_truthy
expect
(
@another_merge_request
.
has_commits?
).
to
be_falsy
end
it
'does not create detached merge request pipeline for forked project'
do
expect
{
subject
}
.
not_to
change
{
@fork_merge_request
.
merge_request_pipelines
.
count
}
end
it
'create detached merge request pipeline for non-fork merge request'
do
subject
...
...
@@ -183,11 +189,25 @@ describe MergeRequests::RefreshService do
.
to
be_detached_merge_request_pipeline
end
it
'create legacy detached merge request pipeline for fork merge request
'
do
subject
context
'when service is hooked by target branch
'
do
let
(
:ref
)
{
'refs/heads/feature'
}
expect
(
@fork_merge_request
.
merge_request_pipelines
.
first
)
.
to
be_legacy_detached_merge_request_pipeline
it
'does not create detached merge request pipeline'
do
expect
{
subject
}
.
not_to
change
{
@merge_request
.
merge_request_pipelines
.
count
}
end
end
context
'when service runs on forked project'
do
let
(
:project
)
{
@fork_project
}
it
'creates legacy detached merge request pipeline for fork merge request'
do
expect
{
subject
}
.
to
change
{
@fork_merge_request
.
merge_request_pipelines
.
count
}.
by
(
1
)
expect
(
@fork_merge_request
.
merge_request_pipelines
.
first
)
.
to
be_legacy_detached_merge_request_pipeline
end
end
context
'when ci_use_merge_request_ref feature flag is false'
do
...
...
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