Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-08-16 03:10:06 +00:00
parent 9b99f2a0a3
commit 2a3313dc5e
7 changed files with 40 additions and 76 deletions

View File

@ -169,11 +169,7 @@ module Ci
end
def all_dependencies
if Feature.enabled?(:preload_associations_jobs_request_api_endpoint, project, default_enabled: :yaml)
strong_memoize(:all_dependencies) do
dependencies.all
end
else
strong_memoize(:all_dependencies) do
dependencies.all
end
end

View File

@ -58,11 +58,7 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord
def all_dependencies
dependencies = super
if Feature.enabled?(:preload_associations_jobs_request_api_endpoint, project, default_enabled: :yaml)
ActiveRecord::Associations::Preloader.new.preload(dependencies, :job_artifacts_archive)
end
ActiveRecord::Associations::Preloader.new.preload(dependencies, :job_artifacts_archive)
dependencies
end
# rubocop: enable CodeReuse/ActiveRecord

View File

@ -16,7 +16,7 @@
aws_tip_deploy_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'deploy-your-application-to-the-aws-elastic-container-service-ecs'),
aws_tip_commands_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'run-aws-commands-from-gitlab-cicd'),
aws_tip_learn_link: help_page_path('ci/cloud_deployment/index.md', anchor: 'aws'),
contains_variable_reference_link: help_page_path('ci/variables/index', anchor: 'troubleshooting-variables-containing-references'),
contains_variable_reference_link: help_page_path('ci/variables/index', anchor: 'use-variables-or-in-other-variables'),
protected_environment_variables_link: help_page_path('ci/variables/index', anchor: 'protect-a-cicd-variable'),
masked_environment_variables_link: help_page_path('ci/variables/index', anchor: 'mask-a-cicd-variable'),
} }

View File

@ -1,8 +0,0 @@
---
name: preload_associations_jobs_request_api_endpoint
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57694
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/326477
milestone: "13.11"
type: development
group: group::pipeline execution
default_enabled: true

View File

@ -557,10 +557,17 @@ end
### Skip reconfirmation
```ruby
user = User.find_by_username '<username>'
user = User.find_by_username('<username>')
user.skip_reconfirmation!
```
### Disable 2fa for single user
```ruby
user = User.find_by_username('<username>')
user.disable_two_factor!
```
### Active users & Historical users
```ruby

View File

@ -112,21 +112,34 @@ job1:
- echo This job does not need any variables
```
You can use variables to help define other variables. Use `$$` to ignore a variable
name inside another variable:
```yaml
variables:
FLAGS: '-al'
LS_CMD: 'ls "$FLAGS" $$TMP_DIR'
script:
- 'eval "$LS_CMD"' # Executes 'ls -al $TMP_DIR'
```
Use the [`value` and `description`](../yaml/index.md#prefill-variables-in-manual-pipelines)
keywords to define [variables that are prefilled](../pipelines/index.md#prefill-variables-in-manual-pipelines)
for [manually-triggered pipelines](../pipelines/index.md#run-a-pipeline-manually).
### Use variables or `$` in other variables
You can use variables inside other variables:
```yaml
job:
variables:
FLAGS: '-al'
LS_CMD: 'ls "$FLAGS"'
script:
- 'eval "$LS_CMD"' # Executes 'ls -al'
```
If you do not want the `$` interpreted as the start of a variable, use `$$` instead:
```yaml
job:
variables:
FLAGS: '-al'
LS_CMD: 'ls "$FLAGS" $$TMP_DIR'
script:
- 'eval "$LS_CMD"' # Executes 'ls -al $TMP_DIR'
```
### Add a CI/CD variable to a project
You can add CI/CD variables to a project's settings. Only project members with the
@ -374,26 +387,6 @@ WARNING:
When you store credentials, there are [security implications](#cicd-variable-security).
If you use AWS keys for example, follow the [Best practices for managing AWS access keys](https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html).
### Troubleshooting variables containing references
When a variable value contains a reference indicated by `$`, it may be expanded
which can lead to unexpected values. Use `$$` to ignore a variable name inside
another variable:
```plaintext
SOME$$VALUE
```
Another workaround is to add a new variable set to the one that contains a
reference:
```yaml
variables:
NEWVAR: $MYVAR
script:
- echo $NEWVAR # outputs SOME$VALUE
```
## Use CI/CD variables in job scripts
All CI/CD variables are set as environment variables in the job's environment.
@ -427,7 +420,7 @@ job_name:
```
In [some cases](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4115#note_157692820)
environment variables might need to be surrounded by quotes to expand properly:
environment variables must be surrounded by quotes to expand properly:
```yaml
job_name:

View File

@ -506,32 +506,12 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end
describe 'preloading job_artifacts_archive' do
context 'when the feature flag is disabled' do
before do
stub_feature_flags(preload_associations_jobs_request_api_endpoint: false)
end
it 'queries the ci_job_artifacts table multiple times' do
expect { request_job }.to exceed_all_query_limit(1).for_model(::Ci::JobArtifact)
end
it 'queries the ci_builds table more than three times' do
expect { request_job }.to exceed_all_query_limit(3).for_model(::Ci::Build)
end
it 'queries the ci_job_artifacts table once only' do
expect { request_job }.not_to exceed_all_query_limit(1).for_model(::Ci::JobArtifact)
end
context 'when the feature flag is enabled' do
before do
stub_feature_flags(preload_associations_jobs_request_api_endpoint: true)
end
it 'queries the ci_job_artifacts table once only' do
expect { request_job }.not_to exceed_all_query_limit(1).for_model(::Ci::JobArtifact)
end
it 'queries the ci_builds table five times' do
expect { request_job }.not_to exceed_all_query_limit(5).for_model(::Ci::Build)
end
it 'queries the ci_builds table five times' do
expect { request_job }.not_to exceed_all_query_limit(5).for_model(::Ci::Build)
end
end
end