Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-11-18 03:09:21 +00:00
parent c48065a833
commit cfaf98a3b2
46 changed files with 299 additions and 430 deletions

View File

@ -51,6 +51,14 @@ export default {
);
},
},
methods: {
showCommentLeft(line) {
return !this.inline || line.left;
},
showCommentRight(line) {
return !this.inline || (line.right && !line.left);
},
},
userColorScheme: window.gon.user_color_scheme,
};
</script>
@ -93,10 +101,7 @@ export default {
:class="line.commentRowClasses"
class="diff-grid-comments diff-tr notes_holder"
>
<div
v-if="!inline || (line.left && line.left.discussions.length)"
class="diff-td notes-content parallel old"
>
<div v-if="showCommentLeft(line)" class="diff-td notes-content parallel old">
<diff-comment-cell
v-if="line.left"
:line="line.left"
@ -106,10 +111,7 @@ export default {
line-position="left"
/>
</div>
<div
v-if="!inline || (line.right && line.right.discussions.length)"
class="diff-td notes-content parallel new"
>
<div v-if="showCommentRight(line)" class="diff-td notes-content parallel new">
<diff-comment-cell
v-if="line.right"
:line="line.right"

View File

@ -69,7 +69,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
}
options = additional_attributes.merge(
diff_view: Feature.enabled?(:unified_diff_lines, @merge_request.project, default_enabled: true) ? "inline" : diff_view,
diff_view: unified_diff_lines_view_type(@merge_request.project),
merge_ref_head_diff: render_merge_ref_head_diff?
)

View File

@ -481,7 +481,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
def endpoint_metadata_url(project, merge_request)
params = request.query_parameters
params[:view] = cookies[:diff_view] if params[:view].blank? && cookies[:diff_view].present?
params[:view] = unified_diff_lines_view_type(project)
if Feature.enabled?(:default_merge_ref_for_diffs, project)
params = params.merge(diff_head: true)

View File

@ -44,12 +44,5 @@ module Types
null: true,
description: 'Pipelines of the commit ordered latest first',
resolver: Resolvers::CommitPipelinesResolver
field :latest_pipeline,
type: Types::Ci::PipelineType,
null: true,
deprecated: { reason: 'Use `pipelines`', milestone: '12.5' },
description: 'Latest pipeline of the commit',
resolver: Resolvers::CommitPipelinesResolver.last
end
end

View File

@ -16,13 +16,5 @@ module Types
description: 'Timestamp of the issue\'s creation'
field :updated_at, Types::TimeType, null: false,
description: 'Timestamp of the issue\'s last activity'
field :token, GraphQL::STRING_TYPE, null: false,
deprecated: { reason: 'Plain text token has been masked for security reasons', milestone: '12.7' },
description: 'API token for the Grafana integration'
def token
object.masked_token
end
end
end

View File

@ -98,11 +98,6 @@ module Types
field :task_completion_status, Types::TaskCompletionStatus, null: false,
description: 'Task completion status of the issue'
field :designs, Types::DesignManagement::DesignCollectionType, null: true,
method: :design_collection,
deprecated: { reason: 'Use `designCollection`', milestone: '12.2' },
description: 'The designs associated with this issue'
field :design_collection, Types::DesignManagement::DesignCollectionType, null: true,
description: 'Collection of design images associated with this issue'

View File

@ -88,9 +88,6 @@ module Types
description: 'Rebase commit SHA of the merge request'
field :rebase_in_progress, GraphQL::BOOLEAN_TYPE, method: :rebase_in_progress?, null: false, calls_gitaly: true,
description: 'Indicates if there is a rebase currently in progress for the merge request'
field :merge_commit_message, GraphQL::STRING_TYPE, method: :default_merge_commit_message, null: true,
deprecated: { reason: 'Use `defaultMergeCommitMessage`', milestone: '11.8' },
description: 'Default merge commit message of the merge request'
field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true,
description: 'Default merge commit message of the merge request'
field :merge_ongoing, GraphQL::BOOLEAN_TYPE, method: :merge_ongoing?, null: false,

View File

@ -203,6 +203,14 @@ module DiffHelper
set_secure_cookie(:diff_view, params.delete(:view), type: CookiesHelper::COOKIE_TYPE_PERMANENT) if params[:view].present?
end
def unified_diff_lines_view_type(project)
if Feature.enabled?(:unified_diff_lines, project, default_enabled: true)
'inline'
else
diff_view
end
end
private
def diff_btn(title, name, selected)

View File

@ -0,0 +1,5 @@
---
title: Fix comment cells not rendering in unified component inline view
merge_request: 47693
author:
type: fixed

View File

@ -0,0 +1,5 @@
---
title: Adds warnings to API response for /lint
merge_request: 47037
author:
type: added

View File

@ -0,0 +1,5 @@
---
title: Fixed diff metadata endpoint being called twice
merge_request: 47265
author:
type: fixed

View File

@ -82,6 +82,10 @@ The process is as follows:
release post (at or prior to X.11 and X.5 releases).
1. Fields meeting criteria are removed in X.0 or X.6.
### List of removed items
View the [fields, enums, and other items we removed](removed_items.md) from the GraphQL API.
## Available queries
The GraphQL API includes the following queries at the root level:

View File

@ -2848,26 +2848,6 @@ type Commit {
"""
id: ID!
"""
Latest pipeline of the commit. Deprecated in 12.5: Use `pipelines`
"""
latestPipeline(
"""
Filter pipelines by the ref they are run for
"""
ref: String
"""
Filter pipelines by the sha of the commit they are run for
"""
sha: String
"""
Filter pipelines by their status
"""
status: PipelineStatusEnum
): Pipeline @deprecated(reason: "Use `pipelines`. Deprecated in 12.5")
"""
Raw commit message
"""
@ -7745,11 +7725,6 @@ type EpicIssue implements CurrentUserTodos & Noteable {
"""
designCollection: DesignCollection
"""
The designs associated with this issue. Deprecated in 12.2: Use `designCollection`
"""
designs: DesignCollection @deprecated(reason: "Use `designCollection`. Deprecated in 12.2")
"""
Indicates discussion is locked on the issue
"""
@ -8554,11 +8529,6 @@ type GrafanaIntegration {
"""
id: ID!
"""
API token for the Grafana integration. Deprecated in 12.7: Plain text token has been masked for security reasons
"""
token: String! @deprecated(reason: "Plain text token has been masked for security reasons. Deprecated in 12.7")
"""
Timestamp of the issue's last activity
"""
@ -10372,11 +10342,6 @@ type Issue implements CurrentUserTodos & Noteable {
"""
designCollection: DesignCollection
"""
The designs associated with this issue. Deprecated in 12.2: Use `designCollection`
"""
designs: DesignCollection @deprecated(reason: "Use `designCollection`. Deprecated in 12.2")
"""
Indicates discussion is locked on the issue
"""
@ -12490,11 +12455,6 @@ type MergeRequest implements CurrentUserTodos & Noteable {
last: Int
): LabelConnection
"""
Default merge commit message of the merge request. Deprecated in 11.8: Use `defaultMergeCommitMessage`
"""
mergeCommitMessage: String @deprecated(reason: "Use `defaultMergeCommitMessage`. Deprecated in 11.8")
"""
SHA of the merge request commit (set once merged)
"""
@ -21322,11 +21282,6 @@ input Timeframe {
}
type Timelog {
"""
Timestamp of when the time tracked was spent at. Deprecated in 12.10: Use `spentAt`
"""
date: Time! @deprecated(reason: "Use `spentAt`. Deprecated in 12.10")
"""
The issue that logged time was added to
"""

View File

@ -7792,49 +7792,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "latestPipeline",
"description": "Latest pipeline of the commit. Deprecated in 12.5: Use `pipelines`",
"args": [
{
"name": "status",
"description": "Filter pipelines by their status",
"type": {
"kind": "ENUM",
"name": "PipelineStatusEnum",
"ofType": null
},
"defaultValue": null
},
{
"name": "ref",
"description": "Filter pipelines by the ref they are run for",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "sha",
"description": "Filter pipelines by the sha of the commit they are run for",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "Pipeline",
"ofType": null
},
"isDeprecated": true,
"deprecationReason": "Use `pipelines`. Deprecated in 12.5"
},
{
"name": "message",
"description": "Raw commit message",
@ -21468,20 +21425,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "designs",
"description": "The designs associated with this issue. Deprecated in 12.2: Use `designCollection`",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "DesignCollection",
"ofType": null
},
"isDeprecated": true,
"deprecationReason": "Use `designCollection`. Deprecated in 12.2"
},
{
"name": "discussionLocked",
"description": "Indicates discussion is locked on the issue",
@ -23703,24 +23646,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "token",
"description": "API token for the Grafana integration. Deprecated in 12.7: Plain text token has been masked for security reasons",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": true,
"deprecationReason": "Plain text token has been masked for security reasons. Deprecated in 12.7"
},
{
"name": "updatedAt",
"description": "Timestamp of the issue's last activity",
@ -28369,20 +28294,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "designs",
"description": "The designs associated with this issue. Deprecated in 12.2: Use `designCollection`",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "DesignCollection",
"ofType": null
},
"isDeprecated": true,
"deprecationReason": "Use `designCollection`. Deprecated in 12.2"
},
{
"name": "discussionLocked",
"description": "Indicates discussion is locked on the issue",
@ -34204,20 +34115,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "mergeCommitMessage",
"description": "Default merge commit message of the merge request. Deprecated in 11.8: Use `defaultMergeCommitMessage`",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": true,
"deprecationReason": "Use `defaultMergeCommitMessage`. Deprecated in 11.8"
},
{
"name": "mergeCommitSha",
"description": "SHA of the merge request commit (set once merged)",
@ -61924,24 +61821,6 @@
"name": "Timelog",
"description": null,
"fields": [
{
"name": "date",
"description": "Timestamp of when the time tracked was spent at. Deprecated in 12.10: Use `spentAt`",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Time",
"ofType": null
}
},
"isDeprecated": true,
"deprecationReason": "Use `spentAt`. Deprecated in 12.10"
},
{
"name": "issue",
"description": "The issue that logged time was added to",

View File

@ -15,6 +15,8 @@ fields and methods on a model are available via GraphQL.
CAUTION: **Caution:**
Fields that are deprecated are marked with **{warning-solid}**.
Items (fields, enums, etc) that have been removed according to our [deprecation process](../index.md#deprecation-process) can be found
in [Removed Items](../removed_items.md).
## Object types
@ -472,7 +474,6 @@ Represents the code coverage summary for a project.
| `description` | String | Description of the commit message |
| `descriptionHtml` | String | The GitLab Flavored Markdown rendering of `description` |
| `id` | ID! | ID (global ID) of the commit |
| `latestPipeline` **{warning-solid}** | Pipeline | **Deprecated:** Use `pipelines`. Deprecated in 12.5 |
| `message` | String | Raw commit message |
| `pipelines` | PipelineConnection | Pipelines of the commit ordered latest first |
| `sha` | String! | SHA1 ID of the commit |
@ -1290,7 +1291,6 @@ Relationship between an epic and an issue.
| `description` | String | Description of the issue |
| `descriptionHtml` | String | The GitLab Flavored Markdown rendering of `description` |
| `designCollection` | DesignCollection | Collection of design images associated with this issue |
| `designs` **{warning-solid}** | DesignCollection | **Deprecated:** Use `designCollection`. Deprecated in 12.2 |
| `discussionLocked` | Boolean! | Indicates discussion is locked on the issue |
| `discussions` | DiscussionConnection! | All discussions on this noteable |
| `downvotes` | Int! | Number of downvotes the issue has received |
@ -1400,7 +1400,6 @@ Autogenerated return type of EpicTreeReorder.
| `enabled` | Boolean! | Indicates whether Grafana integration is enabled |
| `grafanaUrl` | String! | URL for the Grafana host for the Grafana integration |
| `id` | ID! | Internal ID of the Grafana integration |
| `token` **{warning-solid}** | String! | **Deprecated:** Plain text token has been masked for security reasons. Deprecated in 12.7 |
| `updatedAt` | Time! | Timestamp of the issue's last activity |
### Group
@ -1579,7 +1578,6 @@ Represents a recorded measurement (object count) for the Admins.
| `description` | String | Description of the issue |
| `descriptionHtml` | String | The GitLab Flavored Markdown rendering of `description` |
| `designCollection` | DesignCollection | Collection of design images associated with this issue |
| `designs` **{warning-solid}** | DesignCollection | **Deprecated:** Use `designCollection`. Deprecated in 12.2 |
| `discussionLocked` | Boolean! | Indicates discussion is locked on the issue |
| `discussions` | DiscussionConnection! | All discussions on this noteable |
| `downvotes` | Int! | Number of downvotes the issue has received |
@ -1900,7 +1898,6 @@ Autogenerated return type of MarkAsSpamSnippet.
| `iid` | String! | Internal ID of the merge request |
| `inProgressMergeCommitSha` | String | Commit SHA of the merge request if merge is in progress |
| `labels` | LabelConnection | Labels of the merge request |
| `mergeCommitMessage` **{warning-solid}** | String | **Deprecated:** Use `defaultMergeCommitMessage`. Deprecated in 11.8 |
| `mergeCommitSha` | String | SHA of the merge request commit (set once merged) |
| `mergeError` | String | Error message due to a merge error |
| `mergeOngoing` | Boolean! | Indicates if a merge is currently occurring |
@ -3167,7 +3164,6 @@ Represents a historically accurate report about the timebox.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `date` **{warning-solid}** | Time! | **Deprecated:** Use `spentAt`. Deprecated in 12.10 |
| `issue` | Issue | The issue that logged time was added to |
| `note` | Note | The note where the quick action to add the logged time was executed |
| `spentAt` | Time | Timestamp of when the time tracked was spent at |

View File

@ -0,0 +1,17 @@
# GraphQL API removed items
GraphQL is a versionless API, unlike the REST API.
Occasionally, items have to be updated or removed from the GraphQL API.
According to our [process for removing items](index.md#deprecation-process), here are the items that have been removed.
## GitLab 13.6
Fields removed in [GitLab 13.6](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/44866):
| Field name | GraphQL type | Deprecated in | Use instead |
| -------------------- | -------------------- | ------------- | -------------------------- |
| `date` | `Timelog` **(STARTER)** | 12.10 | `spentAt` |
| `designs` | `Issue`, `EpicIssue` | 12.2 | `designCollection` |
| `latestPipeline` | `Commit` | 12.5 | `pipelines` |
| `mergeCommitMessage` | `MergeRequest` | 11.8 | `latestMergeCommitMessage` |
| `token` | `GrafanaIntegration` | 12.7 | None. Plaintext tokens no longer supported for security reasons. |

View File

@ -36,7 +36,20 @@ Example responses:
```json
{
"status": "valid",
"errors": []
"errors": [],
"warnings": []
}
```
- Valid content with warnings:
```json
{
"status": "valid",
"errors": [],
"warnings": ["jobs:job may allow multiple pipelines to run for a single action due to
`rules:when` clause with no `workflow:rules` - read more:
https://docs.gitlab.com/ee/ci/troubleshooting.html#pipeline-warnings"]
}
```
@ -47,7 +60,8 @@ Example responses:
"status": "invalid",
"errors": [
"variables config should be a hash of key value pairs"
]
],
"warnings": []
}
```

View File

@ -16,7 +16,7 @@ is deployed, some [security precautions](../../administration/integration/termin
taken to protect the users.
NOTE: **Note:**
[Shared runners on GitLab.com](../quick_start/README.md#shared-runners) do not
[Shared runners on GitLab.com](../runners/README.md#shared-runners) do not
provide an interactive web terminal. Follow [this
issue](https://gitlab.com/gitlab-org/gitlab/-/issues/24674) for progress on
adding support. For groups and projects hosted on GitLab.com, interactive web

View File

@ -5,229 +5,153 @@ info: To determine the technical writer assigned to the Stage/Group associated w
type: reference
---
# Getting started with GitLab CI/CD
# Get started with GitLab CI/CD
GitLab offers a [continuous integration](https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/) service. For each commit or push to trigger your CI
[pipeline](../pipelines/index.md), you must:
Use this document to get started with
GitLab [continuous integration](https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/).
- Add a [`.gitlab-ci.yml` file](#creating-a-gitlab-ciyml-file) to your repository's root directory.
- Ensure your project is configured to use a [runner](#configuring-a-runner).
Before you start, make sure you have:
The `.gitlab-ci.yml` file defines the structure and order of the pipelines, and determines:
- A project in GitLab that you would like to use CI/CD for.
- Maintainer or owner access for the project.
- What to execute using [GitLab Runner](https://docs.gitlab.com/runner/).
- What decisions to make when specific conditions are encountered. For example, when a process succeeds or fails.
If you are migrating from another CI/CD tool, view this documentation:
A simple pipeline commonly has
three [stages](../yaml/README.md#stages):
- [Migrate from CircleCI](../migration/circleci.md).
- [Migrate from Jenkins](../migration/jenkins.md).
- `build`
- `test`
- `deploy`
## CI/CD process overview
You do not need to use all three stages; stages with no jobs are ignored.
To use GitLab CI/CD:
The pipeline appears under the project's **CI/CD > Pipelines** page. If everything runs OK (no non-zero
return values), you get a green check mark associated with the commit. This makes it easy to see
whether a commit caused any of the tests to fail before you even look at the job (test) log. Many projects use
GitLab's CI service to run the test suite, so developers get immediate feedback if they broke
something.
1. [Ensure you have runners available](#ensure-you-have-runners-available) to run your jobs.
If you don't have a runner, [install GitLab Runner](https://docs.gitlab.com/runner/install/)
and [register a runner](https://docs.gitlab.com/runner/register/) for your instance, project, or group.
1. [Create a `.gitlab-ci.yml` file](#create-a-gitlab-ciyml-file)
at the root of your repository. This file is where you define your CI/CD jobs.
It's also common to use pipelines to automatically deploy
tested code to staging and production environments.
When you commit the file to your repository, the runner runs your jobs.
The job results [are displayed in a pipeline](#view-the-status-of-your-pipeline-and-jobs).
If you're already familiar with general CI/CD concepts, you can review which
[pipeline architectures](../pipelines/pipeline_architectures.md) can be used
in your projects. If you're coming over to GitLab from Jenkins, you can check out
our [reference](../migration/jenkins.md) for converting your pre-existing pipelines
over to our format.
### Ensure you have runners available
This guide assumes that you have:
In GitLab, runners are agents that run your CI/CD jobs.
- A working GitLab instance of version 8.0+ or are using
[GitLab.com](https://gitlab.com).
- A project in GitLab that you would like to use CI for.
- Maintainer or owner access to the project
You might already have runners available for your project, including
[shared runners](../runners/README.md#shared-runners), which are
available to all projects in your GitLab instance.
Let's break it down to pieces and work on solving the GitLab CI/CD puzzle.
To view available runners:
## Creating a `.gitlab-ci.yml` file
- Go to **Settings > CI/CD** and expand **Runners**.
Before you create `.gitlab-ci.yml` let's first explain in brief what this is
all about.
As long as you have at least one runner that's active, with a green circle next to it,
you have a runner available to process your jobs.
### What is `.gitlab-ci.yml`
If no runners are listed on the **Runners** page in the UI, you or an administrator
must [install GitLab Runner](https://docs.gitlab.com/runner/install/) and
[register](https://docs.gitlab.com/runner/register/) at least one runner.
The `.gitlab-ci.yml` file is where you configure what CI does with your project.
It lives in the root of your repository.
If you are testing CI/CD, you can install GitLab Runner and register runners on your local machine.
When your CI/CD jobs run, they will run on your local machine.
On any push to your repository, GitLab will look for the `.gitlab-ci.yml`
file and start jobs on _runners_ according to the contents of the file,
for that commit.
### Create a `.gitlab-ci.yml` file
Because `.gitlab-ci.yml` is in the repository and is version controlled, old
versions still build successfully, forks can easily make use of CI, branches can
have different pipelines and jobs, and you have a single source of truth for CI.
You can read more about the reasons why we are using `.gitlab-ci.yml` [in our
blog about it](https://about.gitlab.com/blog/2015/05/06/why-were-replacing-gitlab-ci-jobs-with-gitlab-ci-dot-yml/).
The `.gitlab-ci.yml` file is a [YAML](https://en.wikipedia.org/wiki/YAML) file where
you configure specific instructions for GitLab CI/CD.
### Creating a simple `.gitlab-ci.yml` file
In this file, you define:
You need to create a file named `.gitlab-ci.yml` in the root directory of your
repository. This is a [YAML](https://en.wikipedia.org/wiki/YAML) file
so you have to pay extra attention to indentation. Always use spaces, not tabs.
- The structure and order of jobs that the runner should execute.
- The decisions the runner should make when specific conditions are encountered.
Below is an example for a Ruby on Rails project:
For example, you might want to run a suite of tests when you commit to
any branch except `master`. When you commit to `master`, you want
to run the same suite, but also publish your application.
```yaml
default:
image: ruby:2.5
before_script:
- apt-get update
- apt-get install -y sqlite3 libsqlite3-dev nodejs
- ruby -v
- which ruby
- gem install bundler --no-document
- bundle install --jobs $(nproc) "${FLAGS[@]}"
All of this is defined in the `.gitlab-ci.yml` file.
rspec:
script:
- bundle exec rspec
To create a `.gitlab-ci.yml` file:
rubocop:
script:
- bundle exec rubocop
```
1. Go to **Project overview > Details**.
1. Above the file list, select the branch you want to commit to,
click the plus icon, then select **New file**:
This is the simplest possible configuration that will work for most Ruby
applications:
![New file](img/new_file_v13_6.png)
1. Define two jobs `rspec` and `rubocop` (the names are arbitrary) with
different commands to be executed.
1. Before every job, the commands defined by `before_script` are executed.
1. For the **File name** type `.gitlab-ci.yml` and in the larger window,
paste this sample code:
The `.gitlab-ci.yml` file defines sets of jobs with constraints of how and when
they should be run. The jobs are defined as top-level elements with a name (in
our case `rspec` and `rubocop`) and always have to contain the `script` keyword.
Jobs are used to create jobs, which are then picked by
[runners](../runners/README.md) and executed within the environment of the runner.
```yaml
build-job:
stage: build
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
What is important is that each job is run independently from each other.
test-job1:
stage: test
script:
- echo "This job tests something"
If you want to check whether the `.gitlab-ci.yml` of your project is valid, there is a
[CI Lint tool](../lint.md) available in every project.
test-job2:
stage: test
script:
- echo "This job tests something, but takes more time than test-job1."
- echo "After the echo commands complete, it runs the sleep command for 20 seconds"
- echo "which simulates a test that runs 20 seconds longer than test-job1"
- sleep 20
You can use the [CI/CD configuration visualization](../yaml/visualization.md) to
see a graphical representation of your `.gitlab-ci.yml`.
deploy-prod:
stage: deploy
script:
- echo "This job deploys something from the $CI_COMMIT_BRANCH branch."
```
For more information and a complete `.gitlab-ci.yml` syntax, please read
[the reference documentation on `.gitlab-ci.yml`](../yaml/README.md).
`$GITLAB_USER_LOGIN` and `$CI_COMMIT_BRANCH` are
[predefined variables](../variables/predefined_variables.md)
that populate when the job runs.
TIP: **Tip:**
A GitLab team member has made an [unofficial visual pipeline editor](https://unofficial.gitlab.tools/visual-pipelines/).
There is a [plan to make it an official part of GitLab](https://gitlab.com/groups/gitlab-org/-/epics/4069)
in the future, but it's available for anyone who wants to try it at the above link.
1. Click **Commit changes**.
### Push `.gitlab-ci.yml` to GitLab
The pipeline starts when the commit is committed.
After you've created a `.gitlab-ci.yml`, you should add it to your Git repository
and push it to GitLab.
#### `.gitlab-ci.yml` tips
```shell
git add .gitlab-ci.yml
git commit -m "Add .gitlab-ci.yml"
git push origin master
```
- If you want the runner to use a Docker image to run the jobs, edit the `.gitlab-ci.yml` file
to include your image name:
Now if you go to the **Pipelines** page you will see that the pipeline is
pending.
```yaml
default:
image: ruby:2.7.2
```
NOTE: **Note:**
If you have a [mirrored repository where GitLab pulls from](../../user/project/repository/repository_mirroring.md#pulling-from-a-remote-repository),
you may need to enable pipeline triggering in your project's
**Settings > Repository > Pull from a remote repository > Trigger pipelines for mirror updates**.
This command tells the runner to use a Ruby image from Docker Hub.
You can also go to the **Commits** page and notice the little pause icon next
to the commit SHA.
- To validate your `.gitlab-ci.yml` file, use the
[CI Lint tool](../lint.md), which is available in every project.
- You can also use [CI/CD configuration visualization](../yaml/visualization.md) to
view a graphical representation of your `.gitlab-ci.yml` file.
- For the complete `.gitlab-ci.yml` syntax, see
[the `.gitlab-ci.yml` reference topic](../yaml/README.md).
![New commit pending](img/new_commit.png)
### View the status of your pipeline and jobs
Clicking on it you will be directed to the jobs page for that specific commit.
When you committed your changes, a pipeline started.
![Single commit jobs page](img/single_commit_status_pending.png)
To view your pipeline:
Notice that there is a pending job which is named after what we wrote in
`.gitlab-ci.yml`. "stuck" indicates that there is no runner configured
yet for this job.
- Go **CI/CD > Pipelines**.
The next step is to configure a runner so that it picks the pending jobs.
A pipeline with three stages should be displayed:
## Configuring a runner
![Three stages](img/three_stages_v13_6.png)
In GitLab, runners run the jobs that you define in `.gitlab-ci.yml`. A runner
can be a virtual machine, a VPS, a bare-metal machine, a Docker container, or
even a cluster of containers. GitLab and the runner communicate through an API,
so the only requirement is that the runner's machine has network access to the
GitLab server.
- To view a visual representation of your pipeline, click the pipeline ID.
A runner can be specific to a certain project or serve multiple projects in
GitLab. If it serves all projects, it's called a _shared runner_.
![Pipeline graph](img/pipeline_graph_v13_6.png)
Find more information about runners in the
[runner](../runners/README.md) documentation.
- To view details of a job, click the job name, for example, `deploy-prod`.
The official runner supported by GitLab is written in Go.
View [the documentation](https://docs.gitlab.com/runner/).
![Job details](img/job_details_v13_6.png)
For a runner to be available in GitLab, you must:
1. [Install GitLab Runner](https://docs.gitlab.com/runner/install/).
1. [Register a runner for your group or project](https://docs.gitlab.com/runner/register/).
When a runner is available, you can view it by
clicking **Settings > CI/CD** and expanding **Runners**.
![Activated runners](img/runners_activated.png)
### Shared runners
If you use [GitLab.com](https://gitlab.com/), you can use the **shared runners**
provided by GitLab.
These are special virtual machines that run on GitLab's infrastructure and can
build any project.
To enable shared runners, go to your project's or group's
**Settings > CI/CD** and click **Enable shared runners**.
[Read more about shared runners](../runners/README.md#shared-runners).
## Viewing the status of your pipeline and jobs
After configuring the runner successfully, you should see the status of your
last commit change from _pending_ to either _running_, _success_ or _failed_.
You can view all pipelines by going to the **Pipelines** page in your project.
![Commit status](img/pipelines_status.png)
Or you can view all jobs, by going to the **Pipelines ➔ Jobs** page.
![Commit status](img/builds_status.png)
By clicking on a job's status, you will be able to see the log of that job.
This is important to diagnose why a job failed or acted differently than
you expected.
![Build log](img/build_log.png)
You are also able to view the status of any commit in the various pages in
GitLab, such as **Commits** and **Merge requests**.
## Additional resources
Visit the [examples README](../examples/README.md) to see a list of examples using GitLab
CI with various languages.
For help making your new pipelines faster and more efficient, see the
[pipeline efficiency documentation](../pipelines/pipeline_efficiency.md).
If the job status is `stuck`, check to ensure a runner is probably configured for the project.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -17,9 +17,9 @@ module API
status 200
response = if error.blank?
{ status: 'valid', errors: [] }
{ status: 'valid', errors: [], warnings: result.warnings }
else
{ status: 'invalid', errors: [error] }
{ status: 'invalid', errors: [error], warnings: result.warnings }
end
response.tap do |response|

View File

@ -28,11 +28,8 @@ dependency_scanning:
.ds-analyzer:
extends: dependency_scanning
allow_failure: true
rules:
- if: $DEPENDENCY_SCANNING_DISABLED
when: never
- if: $CI_COMMIT_BRANCH &&
$GITLAB_FEATURES =~ /\bdependency_scanning\b/
# `rules` must be overridden explicitly by each child job
# see https://gitlab.com/gitlab-org/gitlab/-/issues/218444
script:
- /analyzer run

View File

@ -30,10 +30,8 @@ sast:
.sast-analyzer:
extends: sast
allow_failure: true
rules:
- if: $SAST_DISABLED
when: never
- if: $CI_COMMIT_BRANCH
# `rules` must be overridden explicitly by each child job
# see https://gitlab.com/gitlab-org/gitlab/-/issues/218444
script:
- /analyzer run

View File

@ -14,6 +14,8 @@ variables:
stage: test
image: "$SECURE_ANALYZERS_PREFIX/secrets:$SECRETS_ANALYZER_VERSION"
services: []
# `rules` must be overridden explicitly by each child job
# see https://gitlab.com/gitlab-org/gitlab/-/issues/218444
artifacts:
reports:
secret_detection: gl-secret-detection-report.json

View File

@ -14,6 +14,8 @@
CAUTION: **Caution:**
Fields that are deprecated are marked with **{warning-solid}**.
Items (fields, enums, etc) that have been removed according to our [deprecation process](../index.md#deprecation-process) can be found
in [Removed Items](../removed_items.md).
\
:plain

View File

@ -48,7 +48,7 @@
"@gitlab/visual-review-tools": "1.6.1",
"@rails/actioncable": "^6.0.3-3",
"@rails/ujs": "^6.0.3-2",
"@sourcegraph/code-host-integration": "0.0.50",
"@sourcegraph/code-host-integration": "0.0.52",
"@toast-ui/editor": "^2.5.0",
"@toast-ui/vue-editor": "^2.5.0",
"apollo-cache-inmemory": "^1.6.6",

View File

@ -95,7 +95,8 @@ RSpec.describe Projects::MergeRequestsController do
project,
merge_request,
'json',
diff_head: true))
diff_head: true,
view: 'inline'))
end
end

View File

@ -49,12 +49,29 @@ describe('DiffView', () => {
expect(wrapper.find(DiffExpansionCell).exists()).toBe(true);
});
it('renders a comment row', () => {
const wrapper = createWrapper({
diffLines: [{ renderCommentRow: true, left: { lineDraft: {} } }],
});
expect(wrapper.find(DiffCommentCell).exists()).toBe(true);
});
it.each`
type | side | container | sides | total
${'parallel'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${2}
${'parallel'} | ${'right'} | ${'.new'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${2}
${'inline'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} } }} | ${1}
${'inline'} | ${'right'} | ${'.new'} | ${{ right: { lineDraft: {} } }} | ${1}
${'inline'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${1}
`(
'renders a $type comment row with comment cell on $side',
({ type, container, sides, total }) => {
const wrapper = createWrapper({
diffLines: [{ renderCommentRow: true, ...sides }],
inline: type === 'inline',
});
expect(wrapper.findAll(DiffCommentCell).length).toBe(total);
expect(
wrapper
.find(container)
.find(DiffCommentCell)
.exists(),
).toBe(true);
},
);
it('renders a draft row', () => {
const wrapper = createWrapper({

View File

@ -10,7 +10,7 @@ RSpec.describe GitlabSchema.types['Commit'] do
it 'contains attributes related to commit' do
expect(described_class).to have_graphql_fields(
:id, :sha, :title, :description, :description_html, :message, :title_html, :authored_date,
:author_name, :author_gravatar, :author, :web_url, :web_path, :latest_pipeline,
:author_name, :author_gravatar, :author, :web_url, :web_path,
:pipelines, :signature_html
)
end

View File

@ -7,7 +7,6 @@ RSpec.describe GitlabSchema.types['GrafanaIntegration'] do
%i[
id
grafana_url
token
enabled
created_at
updated_at

View File

@ -17,7 +17,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
fields = %i[id iid title description state reference author assignees updated_by participants labels milestone due_date
confidential discussion_locked upvotes downvotes user_notes_count user_discussions_count web_path web_url relative_position
emails_disabled subscribed time_estimate total_time_spent human_time_estimate human_total_time_spent closed_at created_at updated_at task_completion_status
designs design_collection alert_management_alert severity current_user_todos moved moved_to]
design_collection alert_management_alert severity current_user_todos moved moved_to]
fields.each do |field_name|
expect(described_class).to have_graphql_field(field_name)

View File

@ -21,7 +21,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
diff_refs diff_stats diff_stats_summary
force_remove_source_branch merge_status in_progress_merge_commit_sha
merge_error allow_collaboration should_be_rebased rebase_commit_sha
rebase_in_progress merge_commit_message default_merge_commit_message
rebase_in_progress default_merge_commit_message
merge_ongoing mergeable_discussions_state web_url
source_branch_exists target_branch_exists
upvotes downvotes head_pipeline pipelines task_completion_status

View File

@ -358,4 +358,30 @@ RSpec.describe DiffHelper do
expect(diff_file_path_text(diff_file, max: 10)).to eq("...open.rb")
end
end
describe 'unified_diff_lines_view_type' do
before do
controller.params[:view] = 'parallel'
end
describe 'unified diffs enabled' do
before do
stub_feature_flags(unified_diff_lines: true)
end
it 'returns inline view' do
expect(helper.unified_diff_lines_view_type(project)).to eq 'inline'
end
end
describe 'unified diffs disabled' do
before do
stub_feature_flags(unified_diff_lines: false)
end
it 'returns parallel view' do
expect(helper.unified_diff_lines_view_type(project)).to eq :parallel
end
end
end
end

View File

@ -45,7 +45,6 @@ RSpec.describe 'Getting Grafana Integration' do
it_behaves_like 'a working graphql query'
specify { expect(integration_data['token']).to eql grafana_integration.masked_token }
specify { expect(integration_data['grafanaUrl']).to eql grafana_integration.grafana_url }
specify do

View File

@ -30,7 +30,7 @@ RSpec.describe 'Getting designs related to an issue' do
post_graphql(query(note_fields), current_user: nil)
designs_data = graphql_data['project']['issue']['designs']['designs']
designs_data = graphql_data['project']['issue']['designCollection']['designs']
design_data = designs_data['nodes'].first
note_data = design_data['notes']['nodes'].first
@ -56,7 +56,7 @@ RSpec.describe 'Getting designs related to an issue' do
'issue',
{ iid: design.issue.iid.to_s },
query_graphql_field(
'designs', {}, design_node
'designCollection', {}, design_node
)
)
)

View File

@ -9,12 +9,13 @@ RSpec.describe API::Lint do
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
end
it 'passes validation' do
it 'passes validation without warnings or errors' do
post api('/ci/lint'), params: { content: yaml_content }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash
expect(json_response['status']).to eq('valid')
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq([])
end
@ -26,6 +27,20 @@ RSpec.describe API::Lint do
end
end
context 'with valid .gitlab-ci.yaml with warnings' do
let(:yaml_content) { { job: { script: 'ls', rules: [{ when: 'always' }] } }.to_yaml }
it 'passes validation but returns warnings' do
post api('/ci/lint'), params: { content: yaml_content }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('valid')
expect(json_response['warnings']).not_to be_empty
expect(json_response['status']).to eq('valid')
expect(json_response['errors']).to eq([])
end
end
context 'with an invalid .gitlab_ci.yml' do
context 'with invalid syntax' do
let(:yaml_content) { 'invalid content' }
@ -35,6 +50,7 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('invalid')
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq(['Invalid configuration format'])
end
@ -54,6 +70,7 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('invalid')
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq(['jobs config should contain at least one visible job'])
end
@ -82,7 +99,18 @@ RSpec.describe API::Lint do
let(:project) { create(:project, :repository) }
let(:dry_run) { nil }
RSpec.shared_examples 'valid config' do
RSpec.shared_examples 'valid config with warnings' do
it 'passes validation with warnings' do
ci_lint
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['valid']).to eq(true)
expect(json_response['errors']).to eq([])
expect(json_response['warnings']).not_to be_empty
end
end
RSpec.shared_examples 'valid config without warnings' do
it 'passes validation' do
ci_lint
@ -94,6 +122,7 @@ RSpec.describe API::Lint do
expect(json_response).to be_an Hash
expect(json_response['merged_yaml']).to eq(expected_yaml)
expect(json_response['valid']).to eq(true)
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq([])
end
end
@ -105,6 +134,7 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['merged_yaml']).to eq(yaml_content)
expect(json_response['valid']).to eq(false)
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq(['jobs config should contain at least one visible job'])
end
end
@ -157,6 +187,7 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['merged_yaml']).to eq(nil)
expect(json_response['valid']).to eq(false)
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq(['Insufficient permissions to create a new pipeline'])
end
end
@ -186,7 +217,7 @@ RSpec.describe API::Lint do
)
end
it_behaves_like 'valid config'
it_behaves_like 'valid config without warnings'
end
end
end
@ -242,13 +273,19 @@ RSpec.describe API::Lint do
context 'when running as dry run' do
let(:dry_run) { true }
it_behaves_like 'valid config'
it_behaves_like 'valid config without warnings'
end
context 'when running static validation' do
let(:dry_run) { false }
it_behaves_like 'valid config'
it_behaves_like 'valid config without warnings'
end
context 'With warnings' do
let(:yaml_content) { { job: { script: 'ls', rules: [{ when: 'always' }] } }.to_yaml }
it_behaves_like 'valid config with warnings'
end
end

View File

@ -433,7 +433,7 @@ RSpec.describe 'Git HTTP requests' do
let(:path) { "#{redirect.path}.git" }
it 'downloads get status 200 for redirects' do
clone_get(path, {})
clone_get(path)
expect(response).to have_gitlab_http_status(:ok)
end
@ -465,7 +465,7 @@ RSpec.describe 'Git HTTP requests' do
path: "/#{path}/info/refs?service=git-upload-pack"
})
clone_get(path, env)
clone_get(path, **env)
expect(response).to have_gitlab_http_status(:forbidden)
end
@ -493,7 +493,7 @@ RSpec.describe 'Git HTTP requests' do
it "rejects pulls with 401 Unauthorized for unknown projects (no project existence information leak)" do
user.block
download('doesnt/exist.git', env) do |response|
download('doesnt/exist.git', **env) do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@ -693,7 +693,7 @@ RSpec.describe 'Git HTTP requests' do
end
it 'downloads get status 200' do
clone_get(path, env)
clone_get(path, **env)
expect(response).to have_gitlab_http_status(:ok)
end
@ -745,7 +745,7 @@ RSpec.describe 'Git HTTP requests' do
# We know for sure it is not an information leak since pulls using
# the build token must be allowed.
it "rejects pushes with 403 Forbidden" do
push_get(path, env)
push_get(path, **env)
expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq(git_access_error(:auth_upload))
@ -754,7 +754,7 @@ RSpec.describe 'Git HTTP requests' do
# We are "authenticated" as CI using a valid token here. But we are
# not authorized to see any other project, so return "not found".
it "rejects pulls for other project with 404 Not Found" do
clone_get("#{other_project.full_path}.git", env)
clone_get("#{other_project.full_path}.git", **env)
expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to eq(git_access_error(:project_not_found))
@ -777,7 +777,7 @@ RSpec.describe 'Git HTTP requests' do
let(:project) { create(:project) }
it 'rejects pulls with 404 Not Found' do
clone_get path, env
clone_get(path, **env)
expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to eq(git_access_error(:no_repo))
@ -785,7 +785,7 @@ RSpec.describe 'Git HTTP requests' do
end
it 'rejects pushes with 403 Forbidden' do
push_get path, env
push_get(path, **env)
expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq(git_access_error(:auth_upload))
@ -889,7 +889,7 @@ RSpec.describe 'Git HTTP requests' do
end
it "responds with status 200" do
clone_get(path, env) do |response|
clone_get(path, **env) do |response|
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -913,7 +913,7 @@ RSpec.describe 'Git HTTP requests' do
end
it 'blocks git access when the user did not accept terms', :aggregate_failures do
clone_get(path, env) do |response|
clone_get(path, **env) do |response|
expect(response).to have_gitlab_http_status(:forbidden)
end
@ -932,7 +932,7 @@ RSpec.describe 'Git HTTP requests' do
end
it 'allows clones' do
clone_get(path, env) do |response|
clone_get(path, **env) do |response|
expect(response).to have_gitlab_http_status(:ok)
end
end

View File

@ -1148,10 +1148,10 @@
dependencies:
"@sinonjs/commons" "^1.7.0"
"@sourcegraph/code-host-integration@0.0.50":
version "0.0.50"
resolved "https://registry.yarnpkg.com/@sourcegraph/code-host-integration/-/code-host-integration-0.0.50.tgz#3f91be4c1b117efbf3d49c73033a6b1880db1c70"
integrity sha512-Hf4JeXDnqxOpW8lrkmgzKCYKklQhS6f87j4EPxK//UdjV7W7rtBhsxr6RQqdV2VdVaVCLQW2tfA/tkm0zDk8CQ==
"@sourcegraph/code-host-integration@0.0.52":
version "0.0.52"
resolved "https://registry.yarnpkg.com/@sourcegraph/code-host-integration/-/code-host-integration-0.0.52.tgz#3668364647b9248a0c43d738f7b046c551311338"
integrity sha512-HYmiGuQ3XOQHJIQaRv63Wcdl6y1rgryBrCLzJd/mG5gkkhydTqBuf3wWFKgfL3PCm026OrjXu4PvOYU1fCTZJQ==
"@szmarczak/http-timer@^1.1.2":
version "1.1.2"