Commit 11a4bfc7 authored by Craig Norris's avatar Craig Norris

Merge branch 'docs-update-master-main-verify' into 'master'

Update master references to main in Verify docs 2

See merge request gitlab-org/gitlab!62641
parents 0f35a570 6ca02aa3
...@@ -78,7 +78,7 @@ git init ...@@ -78,7 +78,7 @@ git init
git remote add origin git@gitlab.example.com:<USERNAME>/laravel-sample.git git remote add origin git@gitlab.example.com:<USERNAME>/laravel-sample.git
git add . git add .
git commit -m 'Initial Commit' git commit -m 'Initial Commit'
git push -u origin master git push -u origin main
``` ```
## Configure the production server ## Configure the production server
...@@ -260,7 +260,7 @@ Let's create these three tasks one by one. ...@@ -260,7 +260,7 @@ Let's create these three tasks one by one.
#### Clone the repository #### Clone the repository
The first task will create the `releases` directory (if it doesn't exist), and then clone the `master` branch of the repository (by default) into the new release directory, given by the `$new_release_dir` variable. The first task will create the `releases` directory (if it doesn't exist), and then clone the `main` branch of the repository (by default) into the new release directory, given by the `$new_release_dir` variable.
The `releases` directory will hold all our deployments: The `releases` directory will hold all our deployments:
```php ```php
...@@ -378,14 +378,14 @@ These are persistent data and will be shared to every new release. ...@@ -378,14 +378,14 @@ These are persistent data and will be shared to every new release.
Now, we would need to deploy our app by running `envoy run deploy`, but it won't be necessary since GitLab can handle that for us with CI's [environments](../../environments/index.md), which will be described [later](#setting-up-gitlab-cicd) in this tutorial. Now, we would need to deploy our app by running `envoy run deploy`, but it won't be necessary since GitLab can handle that for us with CI's [environments](../../environments/index.md), which will be described [later](#setting-up-gitlab-cicd) in this tutorial.
Now it's time to commit [Envoy.blade.php](https://gitlab.com/mehranrasulian/laravel-sample/blob/master/Envoy.blade.php) and push it to the `master` branch. Now it's time to commit [Envoy.blade.php](https://gitlab.com/mehranrasulian/laravel-sample/blob/master/Envoy.blade.php) and push it to the `main` branch.
To keep things simple, we commit directly to `master`, without using [feature-branches](../../../topics/gitlab_flow.md#github-flow-as-a-simpler-alternative) since collaboration is beyond the scope of this tutorial. To keep things simple, we commit directly to `main`, without using [feature-branches](../../../topics/gitlab_flow.md#github-flow-as-a-simpler-alternative) since collaboration is beyond the scope of this tutorial.
In a real world project, teams may use [Issue Tracker](../../../user/project/issues/index.md) and [Merge Requests](../../../user/project/merge_requests/index.md) to move their code across branches: In a real world project, teams may use [Issue Tracker](../../../user/project/issues/index.md) and [Merge Requests](../../../user/project/merge_requests/index.md) to move their code across branches:
```shell ```shell
git add Envoy.blade.php git add Envoy.blade.php
git commit -m 'Add Envoy' git commit -m 'Add Envoy'
git push origin master git push origin main
``` ```
## Continuous Integration with GitLab ## Continuous Integration with GitLab
...@@ -474,7 +474,7 @@ Let's commit the `Dockerfile` file. ...@@ -474,7 +474,7 @@ Let's commit the `Dockerfile` file.
```shell ```shell
git add Dockerfile git add Dockerfile
git commit -m 'Add Dockerfile' git commit -m 'Add Dockerfile'
git push origin master git push origin main
``` ```
### Setting up GitLab CI/CD ### Setting up GitLab CI/CD
...@@ -523,7 +523,7 @@ deploy_production: ...@@ -523,7 +523,7 @@ deploy_production:
url: http://192.168.1.1 url: http://192.168.1.1
when: manual when: manual
only: only:
- master - main
``` ```
That's a lot to take in, isn't it? Let's run through it step by step. That's a lot to take in, isn't it? Let's run through it step by step.
...@@ -595,7 +595,7 @@ If the SSH keys have added successfully, we can run Envoy. ...@@ -595,7 +595,7 @@ If the SSH keys have added successfully, we can run Envoy.
As mentioned before, GitLab supports [Continuous Delivery](https://about.gitlab.com/blog/2016/08/05/continuous-integration-delivery-and-deployment-with-gitlab/#continuous-delivery) methods as well. As mentioned before, GitLab supports [Continuous Delivery](https://about.gitlab.com/blog/2016/08/05/continuous-integration-delivery-and-deployment-with-gitlab/#continuous-delivery) methods as well.
The [environment](../../yaml/README.md#environment) keyword tells GitLab that this job deploys to the `production` environment. The [environment](../../yaml/README.md#environment) keyword tells GitLab that this job deploys to the `production` environment.
The `url` keyword is used to generate a link to our application on the GitLab Environments page. The `url` keyword is used to generate a link to our application on the GitLab Environments page.
The `only` keyword tells GitLab CI/CD that the job should be executed only when the pipeline is building the `master` branch. The `only` keyword tells GitLab CI/CD that the job should be executed only when the pipeline is building the `main` branch.
Lastly, `when: manual` is used to turn the job from running automatically to a manual action. Lastly, `when: manual` is used to turn the job from running automatically to a manual action.
```yaml ```yaml
...@@ -616,7 +616,7 @@ deploy_production: ...@@ -616,7 +616,7 @@ deploy_production:
url: http://192.168.1.1 url: http://192.168.1.1
when: manual when: manual
only: only:
- master - main
``` ```
You may also want to add another job for [staging environment](https://about.gitlab.com/blog/2021/02/05/ci-deployment-and-environments/), to final test your application before deploying to production. You may also want to add another job for [staging environment](https://about.gitlab.com/blog/2021/02/05/ci-deployment-and-environments/), to final test your application before deploying to production.
...@@ -624,7 +624,7 @@ You may also want to add another job for [staging environment](https://about.git ...@@ -624,7 +624,7 @@ You may also want to add another job for [staging environment](https://about.git
### Turn on GitLab CI/CD ### Turn on GitLab CI/CD
We have prepared everything we need to test and deploy our app with GitLab CI/CD. We have prepared everything we need to test and deploy our app with GitLab CI/CD.
To do that, commit and push `.gitlab-ci.yml` to the `master` branch. It will trigger a pipeline, which you can watch live under your project's **Pipelines**. To do that, commit and push `.gitlab-ci.yml` to the `main` branch. It will trigger a pipeline, which you can watch live under your project's **Pipelines**.
![pipelines page](img/pipelines_page.png) ![pipelines page](img/pipelines_page.png)
......
...@@ -82,7 +82,7 @@ job1: ...@@ -82,7 +82,7 @@ job1:
- echo This rule uses parentheses. - echo This rule uses parentheses.
only: only:
variables: variables:
- ($CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "develop") && $MY_VARIABLE - ($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop") && $MY_VARIABLE
``` ```
### `only:changes` / `except:changes` examples ### `only:changes` / `except:changes` examples
......
...@@ -70,7 +70,7 @@ build: ...@@ -70,7 +70,7 @@ build:
stage: build stage: build
script: ./build script: ./build
only: only:
- master - main
test: test:
stage: test stage: test
...@@ -82,7 +82,7 @@ deploy: ...@@ -82,7 +82,7 @@ deploy:
stage: deploy stage: deploy
script: ./deploy script: ./deploy
only: only:
- master - main
``` ```
#### Excluding certain jobs #### Excluding certain jobs
...@@ -103,7 +103,7 @@ To achieve this, you can configure your `.gitlab-ci.yml` file as follows: ...@@ -103,7 +103,7 @@ To achieve this, you can configure your `.gitlab-ci.yml` file as follows:
``` yaml ``` yaml
.only-default: &only-default .only-default: &only-default
only: only:
- master - main
- merge_requests - merge_requests
- tags - tags
......
...@@ -209,7 +209,7 @@ jobs: ...@@ -209,7 +209,7 @@ jobs:
deploy: deploy:
branches: branches:
only: only:
- master - main
- /rc-.*/ - /rc-.*/
``` ```
...@@ -221,7 +221,7 @@ deploy_prod: ...@@ -221,7 +221,7 @@ deploy_prod:
script: script:
- echo "Deploy to production server" - echo "Deploy to production server"
rules: rules:
- if: '$CI_COMMIT_BRANCH == "master"' - if: '$CI_COMMIT_BRANCH == "main"'
``` ```
### Caching ### Caching
......
...@@ -318,7 +318,7 @@ Markdown code embeds the test coverage report badge of the `coverage` job ...@@ -318,7 +318,7 @@ Markdown code embeds the test coverage report badge of the `coverage` job
into your `README.md`: into your `README.md`:
```markdown ```markdown
![coverage](https://gitlab.com/gitlab-org/gitlab/badges/master/coverage.svg?job=coverage) ![coverage](https://gitlab.com/gitlab-org/gitlab/badges/main/coverage.svg?job=coverage)
``` ```
### Badge styles ### Badge styles
...@@ -331,7 +331,7 @@ Pipeline badges can be rendered in different styles by adding the `style=style_n ...@@ -331,7 +331,7 @@ Pipeline badges can be rendered in different styles by adding the `style=style_n
https://gitlab.example.com/<namespace>/<project>/badges/<branch>/coverage.svg?style=flat https://gitlab.example.com/<namespace>/<project>/badges/<branch>/coverage.svg?style=flat
``` ```
![Badge flat style](https://gitlab.com/gitlab-org/gitlab/badges/master/coverage.svg?job=coverage&style=flat) ![Badge flat style](https://gitlab.com/gitlab-org/gitlab/badges/main/coverage.svg?job=coverage&style=flat)
- Flat square ([Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/30120) in GitLab 11.8): - Flat square ([Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/30120) in GitLab 11.8):
...@@ -339,7 +339,7 @@ Pipeline badges can be rendered in different styles by adding the `style=style_n ...@@ -339,7 +339,7 @@ Pipeline badges can be rendered in different styles by adding the `style=style_n
https://gitlab.example.com/<namespace>/<project>/badges/<branch>/coverage.svg?style=flat-square https://gitlab.example.com/<namespace>/<project>/badges/<branch>/coverage.svg?style=flat-square
``` ```
![Badge flat square style](https://gitlab.com/gitlab-org/gitlab/badges/master/coverage.svg?job=coverage&style=flat-square) ![Badge flat square style](https://gitlab.com/gitlab-org/gitlab/badges/main/coverage.svg?job=coverage&style=flat-square)
### Custom badge text ### Custom badge text
...@@ -348,10 +348,10 @@ Pipeline badges can be rendered in different styles by adding the `style=style_n ...@@ -348,10 +348,10 @@ Pipeline badges can be rendered in different styles by adding the `style=style_n
The text for a badge can be customized to differentiate between multiple coverage jobs that run in the same pipeline. Customize the badge text and width by adding the `key_text=custom_text` and `key_width=custom_key_width` parameters to the URL: The text for a badge can be customized to differentiate between multiple coverage jobs that run in the same pipeline. Customize the badge text and width by adding the `key_text=custom_text` and `key_width=custom_key_width` parameters to the URL:
```plaintext ```plaintext
https://gitlab.com/gitlab-org/gitlab/badges/master/coverage.svg?job=karma&key_text=Frontend+Coverage&key_width=130 https://gitlab.com/gitlab-org/gitlab/badges/main/coverage.svg?job=karma&key_text=Frontend+Coverage&key_width=130
``` ```
![Badge with custom text and width](https://gitlab.com/gitlab-org/gitlab/badges/master/coverage.svg?job=karma&key_text=Frontend+Coverage&key_width=130) ![Badge with custom text and width](https://gitlab.com/gitlab-org/gitlab/badges/main/coverage.svg?job=karma&key_text=Frontend+Coverage&key_width=130)
<!-- ## Troubleshooting <!-- ## Troubleshooting
......
...@@ -56,7 +56,7 @@ and it creates a dependent pipeline relation visible on the ...@@ -56,7 +56,7 @@ and it creates a dependent pipeline relation visible on the
trigger_pipeline: trigger_pipeline:
stage: deploy stage: deploy
script: script:
- curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master "https://gitlab.example.com/api/v4/projects/9/trigger/pipeline" - curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=main "https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"
only: only:
- tags - tags
``` ```
...@@ -81,7 +81,7 @@ build_submodule: ...@@ -81,7 +81,7 @@ build_submodule:
stage: test stage: test
script: script:
- apt update && apt install -y unzip - apt update && apt install -y unzip
- curl --location --output artifacts.zip "https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/master/download?job=test&job_token=$CI_JOB_TOKEN" - curl --location --output artifacts.zip "https://gitlab.example.com/api/v4/projects/1/jobs/artifacts/main/download?job=test&job_token=$CI_JOB_TOKEN"
- unzip artifacts.zip - unzip artifacts.zip
only: only:
- tags - tags
...@@ -178,7 +178,7 @@ To trigger a job from a webhook of another project you need to add the following ...@@ -178,7 +178,7 @@ To trigger a job from a webhook of another project you need to add the following
webhook URL for Push and Tag events (change the project ID, ref and token): webhook URL for Push and Tag events (change the project ID, ref and token):
```plaintext ```plaintext
https://gitlab.example.com/api/v4/projects/9/ref/master/trigger/pipeline?token=TOKEN https://gitlab.example.com/api/v4/projects/9/ref/main/trigger/pipeline?token=TOKEN
``` ```
You should pass `ref` as part of the URL, to take precedence over `ref` from You should pass `ref` as part of the URL, to take precedence over `ref` from
...@@ -250,7 +250,7 @@ and the script of the `upload_package` job is run: ...@@ -250,7 +250,7 @@ and the script of the `upload_package` job is run:
```shell ```shell
curl --request POST \ curl --request POST \
--form token=TOKEN \ --form token=TOKEN \
--form ref=master \ --form ref=main \
--form "variables[UPLOAD_TO_S3]=true" \ --form "variables[UPLOAD_TO_S3]=true" \
"https://gitlab.example.com/api/v4/projects/9/trigger/pipeline" "https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"
``` ```
......
...@@ -434,7 +434,7 @@ Example job log output: ...@@ -434,7 +434,7 @@ Example job log output:
export CI_JOB_ID="50" export CI_JOB_ID="50"
export CI_COMMIT_SHA="1ecfd275763eff1d6b4844ea3168962458c9f27a" export CI_COMMIT_SHA="1ecfd275763eff1d6b4844ea3168962458c9f27a"
export CI_COMMIT_SHORT_SHA="1ecfd275" export CI_COMMIT_SHORT_SHA="1ecfd275"
export CI_COMMIT_REF_NAME="master" export CI_COMMIT_REF_NAME="main"
export CI_REPOSITORY_URL="https://gitlab-ci-token:[masked]@example.com/gitlab-org/gitlab-foss.git" export CI_REPOSITORY_URL="https://gitlab-ci-token:[masked]@example.com/gitlab-org/gitlab-foss.git"
export CI_COMMIT_TAG="1.0.0" export CI_COMMIT_TAG="1.0.0"
export CI_JOB_NAME="spec:other" export CI_JOB_NAME="spec:other"
...@@ -815,7 +815,7 @@ as well as from in a variable: ...@@ -815,7 +815,7 @@ as well as from in a variable:
```yaml ```yaml
variables: variables:
MYSTRING: 'master' MYSTRING: 'main'
MYREGEX: '/^mast.*/' MYREGEX: '/^mast.*/'
testdirect: testdirect:
...@@ -943,8 +943,8 @@ if [[ -d "/builds/gitlab-examples/ci-debug-trace/.git" ]]; then ...@@ -943,8 +943,8 @@ if [[ -d "/builds/gitlab-examples/ci-debug-trace/.git" ]]; then
++ CI_PROJECT_VISIBILITY=public ++ CI_PROJECT_VISIBILITY=public
++ export CI_PROJECT_REPOSITORY_LANGUAGES= ++ export CI_PROJECT_REPOSITORY_LANGUAGES=
++ CI_PROJECT_REPOSITORY_LANGUAGES= ++ CI_PROJECT_REPOSITORY_LANGUAGES=
++ export CI_DEFAULT_BRANCH=master ++ export CI_DEFAULT_BRANCH=main
++ CI_DEFAULT_BRANCH=master ++ CI_DEFAULT_BRANCH=main
++ export CI_REGISTRY=registry.gitlab.com ++ export CI_REGISTRY=registry.gitlab.com
++ CI_REGISTRY=registry.gitlab.com ++ CI_REGISTRY=registry.gitlab.com
++ export CI_API_V4_URL=https://gitlab.com/api/v4 ++ export CI_API_V4_URL=https://gitlab.com/api/v4
...@@ -961,10 +961,10 @@ if [[ -d "/builds/gitlab-examples/ci-debug-trace/.git" ]]; then ...@@ -961,10 +961,10 @@ if [[ -d "/builds/gitlab-examples/ci-debug-trace/.git" ]]; then
++ CI_COMMIT_SHORT_SHA=dd648b2e ++ CI_COMMIT_SHORT_SHA=dd648b2e
++ export CI_COMMIT_BEFORE_SHA=0000000000000000000000000000000000000000 ++ export CI_COMMIT_BEFORE_SHA=0000000000000000000000000000000000000000
++ CI_COMMIT_BEFORE_SHA=0000000000000000000000000000000000000000 ++ CI_COMMIT_BEFORE_SHA=0000000000000000000000000000000000000000
++ export CI_COMMIT_REF_NAME=master ++ export CI_COMMIT_REF_NAME=main
++ CI_COMMIT_REF_NAME=master ++ CI_COMMIT_REF_NAME=main
++ export CI_COMMIT_REF_SLUG=master ++ export CI_COMMIT_REF_SLUG=main
++ CI_COMMIT_REF_SLUG=master ++ CI_COMMIT_REF_SLUG=main
... ...
``` ```
......
...@@ -1029,7 +1029,7 @@ levels. For example: ...@@ -1029,7 +1029,7 @@ levels. For example:
URL: "http://my-url.internal" URL: "http://my-url.internal"
IMPORTANT_VAR: "the details" IMPORTANT_VAR: "the details"
only: only:
- master - main
- stable - stable
tags: tags:
- production - production
...@@ -1062,7 +1062,7 @@ rspec: ...@@ -1062,7 +1062,7 @@ rspec:
IMPORTANT_VAR: "the details" IMPORTANT_VAR: "the details"
GITLAB: "is-awesome" GITLAB: "is-awesome"
only: only:
- master - main
- stable - stable
tags: tags:
- docker - docker
...@@ -2390,7 +2390,7 @@ For example: ...@@ -2390,7 +2390,7 @@ For example:
```yaml ```yaml
deploy to production: deploy to production:
stage: deploy stage: deploy
script: git push production HEAD:master script: git push production HEAD:main
environment: production environment: production
``` ```
...@@ -2412,7 +2412,7 @@ Set a name for an [environment](../environments/index.md). For example: ...@@ -2412,7 +2412,7 @@ Set a name for an [environment](../environments/index.md). For example:
```yaml ```yaml
deploy to production: deploy to production:
stage: deploy stage: deploy
script: git push production HEAD:master script: git push production HEAD:main
environment: environment:
name: production name: production
``` ```
...@@ -2447,7 +2447,7 @@ Set a URL for an [environment](../environments/index.md). For example: ...@@ -2447,7 +2447,7 @@ Set a URL for an [environment](../environments/index.md). For example:
```yaml ```yaml
deploy to production: deploy to production:
stage: deploy stage: deploy
script: git push production HEAD:master script: git push production HEAD:main
environment: environment:
name: production name: production
url: https://prod.example.com url: https://prod.example.com
......
...@@ -26,7 +26,7 @@ Array with `include` method implied: ...@@ -26,7 +26,7 @@ Array with `include` method implied:
```yaml ```yaml
include: include:
- 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' - 'https://gitlab.com/awesome-project/raw/main/.before-script-template.yml'
- '/templates/.after-script-template.yml' - '/templates/.after-script-template.yml'
``` ```
...@@ -34,21 +34,21 @@ Single string with `include` method specified explicitly: ...@@ -34,21 +34,21 @@ Single string with `include` method specified explicitly:
```yaml ```yaml
include: include:
remote: 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' remote: 'https://gitlab.com/awesome-project/raw/main/.before-script-template.yml'
``` ```
Array with `include:remote` being the single item: Array with `include:remote` being the single item:
```yaml ```yaml
include: include:
- remote: 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' - remote: 'https://gitlab.com/awesome-project/raw/main/.before-script-template.yml'
``` ```
Array with multiple `include` methods specified explicitly: Array with multiple `include` methods specified explicitly:
```yaml ```yaml
include: include:
- remote: 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' - remote: 'https://gitlab.com/awesome-project/raw/main/.before-script-template.yml'
- local: '/templates/.after-script-template.yml' - local: '/templates/.after-script-template.yml'
- template: Auto-DevOps.gitlab-ci.yml - template: Auto-DevOps.gitlab-ci.yml
``` ```
...@@ -57,11 +57,11 @@ Array mixed syntax: ...@@ -57,11 +57,11 @@ Array mixed syntax:
```yaml ```yaml
include: include:
- 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' - 'https://gitlab.com/awesome-project/raw/main/.before-script-template.yml'
- '/templates/.after-script-template.yml' - '/templates/.after-script-template.yml'
- template: Auto-DevOps.gitlab-ci.yml - template: Auto-DevOps.gitlab-ci.yml
- project: 'my-group/my-project' - project: 'my-group/my-project'
ref: master ref: main
file: '/templates/.gitlab-ci-template.yml' file: '/templates/.gitlab-ci-template.yml'
``` ```
...@@ -70,7 +70,7 @@ include: ...@@ -70,7 +70,7 @@ include:
In the following example, the content of `.before-script-template.yml` is In the following example, the content of `.before-script-template.yml` is
automatically fetched and evaluated along with the content of `.gitlab-ci.yml`. automatically fetched and evaluated along with the content of `.gitlab-ci.yml`.
Content of `https://gitlab.com/awesome-project/raw/master/.before-script-template.yml`: Content of `https://gitlab.com/awesome-project/raw/main/.before-script-template.yml`:
```yaml ```yaml
default: default:
...@@ -83,7 +83,7 @@ default: ...@@ -83,7 +83,7 @@ default:
Content of `.gitlab-ci.yml`: Content of `.gitlab-ci.yml`:
```yaml ```yaml
include: 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml' include: 'https://gitlab.com/awesome-project/raw/main/.before-script-template.yml'
rspec: rspec:
script: script:
...@@ -112,7 +112,7 @@ production: ...@@ -112,7 +112,7 @@ production:
name: production name: production
url: https://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN url: https://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
only: only:
- master - main
``` ```
Content of `.gitlab-ci.yml`: Content of `.gitlab-ci.yml`:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment