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
43844925
Commit
43844925
authored
Feb 25, 2021
by
Mitchell Cash
Committed by
Thong Kuah
Feb 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Auto DevOps deploys that use a default branch that's not `master`
parent
dbe5012f
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
222 additions
and
209 deletions
+222
-209
changelogs/unreleased/auto-devops-default-branch-deploy.yml
changelogs/unreleased/auto-devops-default-branch-deploy.yml
+5
-0
lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
+9
-9
lib/gitlab/ci/templates/Jobs/Deploy.latest.gitlab-ci.yml
lib/gitlab/ci/templates/Jobs/Deploy.latest.gitlab-ci.yml
+9
-9
lib/gitlab/ci/templates/Jobs/Deploy/EC2.gitlab-ci.yml
lib/gitlab/ci/templates/Jobs/Deploy/EC2.gitlab-ci.yml
+2
-2
lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml
lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml
+6
-6
spec/factories/projects.rb
spec/factories/projects.rb
+1
-1
spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
...ib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
+190
-182
No files found.
changelogs/unreleased/auto-devops-default-branch-deploy.yml
0 → 100644
View file @
43844925
---
title
:
Fix Auto DevOps deploys that use a default branch that's not named 'master'
merge_request
:
53280
author
:
Mitchell Cash @MitchellCash
type
:
fixed
lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
View file @
43844925
...
...
@@ -23,7 +23,7 @@ review:
rules
:
-
if
:
'
$CI_KUBERNETES_ACTIVE
==
null
||
$CI_KUBERNETES_ACTIVE
==
""'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
...
...
@@ -44,7 +44,7 @@ stop_review:
rules
:
-
if
:
'
$CI_KUBERNETES_ACTIVE
==
null
||
$CI_KUBERNETES_ACTIVE
==
""'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
...
...
@@ -73,7 +73,7 @@ staging:
rules
:
-
if
:
'
$CI_KUBERNETES_ACTIVE
==
null
||
$CI_KUBERNETES_ACTIVE
==
""'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$STAGING_ENABLED'
...
...
@@ -98,7 +98,7 @@ canary:
rules
:
-
if
:
'
$CI_KUBERNETES_ACTIVE
==
null
||
$CI_KUBERNETES_ACTIVE
==
""'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CANARY_ENABLED'
when
:
manual
...
...
@@ -136,7 +136,7 @@ production:
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
production_manual
:
<<
:
*production_template
...
...
@@ -148,9 +148,9 @@ production_manual:
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
&&
$STAGING_ENABLED'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
&&
$STAGING_ENABLED'
when
:
manual
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
&&
$CANARY_ENABLED'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
&&
$CANARY_ENABLED'
when
:
manual
# This job implements incremental rollout on for every push to `master`.
...
...
@@ -184,7 +184,7 @@ production_manual:
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE
==
"timed"'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
# $INCREMENTAL_ROLLOUT_ENABLED is for compatibility with pre-GitLab 11.4 syntax
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE
==
"manual"
||
$INCREMENTAL_ROLLOUT_ENABLED'
...
...
@@ -197,7 +197,7 @@ production_manual:
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE
==
"manual"'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE
==
"timed"'
when
:
delayed
...
...
lib/gitlab/ci/templates/Jobs/Deploy.latest.gitlab-ci.yml
View file @
43844925
...
...
@@ -23,7 +23,7 @@ review:
rules
:
-
if
:
'
$CI_KUBERNETES_ACTIVE
==
null
||
$CI_KUBERNETES_ACTIVE
==
""'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
...
...
@@ -44,7 +44,7 @@ stop_review:
rules
:
-
if
:
'
$CI_KUBERNETES_ACTIVE
==
null
||
$CI_KUBERNETES_ACTIVE
==
""'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
...
...
@@ -73,7 +73,7 @@ staging:
rules
:
-
if
:
'
$CI_KUBERNETES_ACTIVE
==
null
||
$CI_KUBERNETES_ACTIVE
==
""'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$STAGING_ENABLED'
...
...
@@ -98,7 +98,7 @@ canary:
rules
:
-
if
:
'
$CI_KUBERNETES_ACTIVE
==
null
||
$CI_KUBERNETES_ACTIVE
==
""'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CANARY_ENABLED'
when
:
manual
...
...
@@ -135,7 +135,7 @@ production:
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
production_manual
:
<<
:
*production_template
...
...
@@ -147,9 +147,9 @@ production_manual:
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
&&
$STAGING_ENABLED'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
&&
$STAGING_ENABLED'
when
:
manual
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
&&
$CANARY_ENABLED'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
&&
$CANARY_ENABLED'
when
:
manual
# This job implements incremental rollout on for every push to `master`.
...
...
@@ -181,7 +181,7 @@ production_manual:
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE
==
"timed"'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
# $INCREMENTAL_ROLLOUT_ENABLED is for compatibility with pre-GitLab 11.4 syntax
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE
==
"manual"
||
$INCREMENTAL_ROLLOUT_ENABLED'
...
...
@@ -194,7 +194,7 @@ production_manual:
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE
==
"manual"'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$INCREMENTAL_ROLLOUT_MODE
==
"timed"'
when
:
delayed
...
...
lib/gitlab/ci/templates/Jobs/Deploy/EC2.gitlab-ci.yml
View file @
43844925
...
...
@@ -20,7 +20,7 @@ review_ec2:
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CI_COMMIT_TAG
||
$CI_COMMIT_BRANCH'
...
...
@@ -34,6 +34,6 @@ production_ec2:
when
:
never
-
if
:
'
$CI_KUBERNETES_ACTIVE'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CI_COMMIT_TAG
||
$CI_COMMIT_BRANCH'
lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml
View file @
43844925
...
...
@@ -46,7 +46,7 @@ review_ecs:
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CI_COMMIT_TAG
||
$CI_COMMIT_BRANCH'
...
...
@@ -62,7 +62,7 @@ stop_review_ecs:
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CI_COMMIT_TAG
||
$CI_COMMIT_BRANCH'
when
:
manual
...
...
@@ -81,7 +81,7 @@ review_fargate:
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CI_COMMIT_TAG
||
$CI_COMMIT_BRANCH'
...
...
@@ -97,7 +97,7 @@ stop_review_fargate:
when
:
never
-
if
:
'
$REVIEW_DISABLED'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CI_COMMIT_TAG
||
$CI_COMMIT_BRANCH'
when
:
manual
...
...
@@ -109,7 +109,7 @@ production_ecs:
when
:
never
-
if
:
'
$CI_KUBERNETES_ACTIVE'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CI_COMMIT_TAG
||
$CI_COMMIT_BRANCH'
...
...
@@ -120,6 +120,6 @@ production_fargate:
when
:
never
-
if
:
'
$CI_KUBERNETES_ACTIVE'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
!=
"master"
'
-
if
:
'
$CI_COMMIT_BRANCH
!=
$CI_DEFAULT_BRANCH
'
when
:
never
-
if
:
'
$CI_COMMIT_TAG
||
$CI_COMMIT_BRANCH'
spec/factories/projects.rb
View file @
43844925
...
...
@@ -194,7 +194,7 @@ FactoryBot.define do
filename
,
content
,
message:
"Automatically created file
#{
filename
}
"
,
branch_name:
'master'
branch_name:
project
.
default_branch_or_master
)
end
end
...
...
spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
View file @
43844925
...
...
@@ -3,10 +3,16 @@
require
'spec_helper'
RSpec
.
describe
'Auto-DevOps.gitlab-ci.yml'
do
using
RSpec
::
Parameterized
::
TableSyntax
subject
(
:template
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'Auto-DevOps'
)
}
where
(
:default_branch
)
do
%w[master main]
end
with_them
do
describe
'the created pipeline'
do
let
(
:default_branch
)
{
'master'
}
let
(
:pipeline_branch
)
{
default_branch
}
let
(
:project
)
{
create
(
:project
,
:auto_devops
,
:custom_repo
,
files:
{
'README.md'
=>
''
})
}
let
(
:user
)
{
project
.
owner
}
...
...
@@ -15,9 +21,9 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
let
(
:build_names
)
{
pipeline
.
builds
.
pluck
(
:name
)
}
before
do
stub_application_setting
(
default_branch_name:
default_branch
)
stub_ci_pipeline_yaml_file
(
template
.
content
)
allow_any_instance_of
(
Ci
::
BuildScheduleWorker
).
to
receive
(
:perform
).
and_return
(
true
)
allow
(
project
).
to
receive
(
:default_branch
).
and_return
(
default_branch
)
end
shared_examples
'no Kubernetes deployment job'
do
...
...
@@ -84,7 +90,7 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
let
(
:pipeline_branch
)
{
'patch-1'
}
before
do
project
.
repository
.
create_branch
(
pipeline
_branch
)
project
.
repository
.
create_branch
(
pipeline_branch
,
default
_branch
)
end
%w(review_ecs review_fargate)
.
each
do
|
job
|
...
...
@@ -190,7 +196,7 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
let
(
:pipeline_branch
)
{
'patch-1'
}
before
do
project
.
repository
.
create_branch
(
pipeline
_branch
)
project
.
repository
.
create_branch
(
pipeline_branch
,
default
_branch
)
end
it
'does not include rollout jobs besides review'
do
...
...
@@ -234,11 +240,12 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
with_them
do
let
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
files
)
}
let
(
:user
)
{
project
.
owner
}
let
(
:service
)
{
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
ref:
'master'
)
}
let
(
:service
)
{
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
ref:
default_branch
)
}
let
(
:pipeline
)
{
service
.
execute
(
:push
)
}
let
(
:build_names
)
{
pipeline
.
builds
.
pluck
(
:name
)
}
before
do
stub_application_setting
(
default_branch_name:
default_branch
)
stub_ci_pipeline_yaml_file
(
template
.
content
)
allow_any_instance_of
(
Ci
::
BuildScheduleWorker
).
to
receive
(
:perform
).
and_return
(
true
)
variables
.
each
do
|
(
key
,
value
)
|
...
...
@@ -252,4 +259,5 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do
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