diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ci/environments.md | 64 | ||||
-rw-r--r-- | doc/ci/pipelines/index.md | 1 | ||||
-rw-r--r-- | doc/ci/pipelines/job_artifacts.md | 1 | ||||
-rw-r--r-- | doc/ci/pipelines/schedules.md | 1 | ||||
-rw-r--r-- | doc/ci/pipelines/settings.md | 1 | ||||
-rw-r--r-- | doc/ci/yaml/README.md | 19 | ||||
-rw-r--r-- | doc/user/incident_management/index.md | 2 |
7 files changed, 89 insertions, 0 deletions
diff --git a/doc/ci/environments.md b/doc/ci/environments.md index 2268ab309c3..5bb1e221781 100644 --- a/doc/ci/environments.md +++ b/doc/ci/environments.md @@ -156,6 +156,70 @@ Starting with GitLab 9.3, the environment URL is exposed to the Runner via - `.gitlab-ci.yml`. - The external URL from the environment if not defined in `.gitlab-ci.yml`. +#### Set dynamic environment URLs after a job finishes + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/17066) in GitLab 12.9. + +In a job script, you can specify a static [environment URL](#using-the-environment-url). +However, there may be times when you want a dynamic URL. For example, +if you deploy a Review App to an external hosting +service that generates a random URL per deployment, like `https://94dd65b.amazonaws.com/qa-lambda-1234567`, +you don't know the URL before the deployment script finishes. +If you want to use the environment URL in GitLab, you would have to update it manually. + +To address this problem, you can configure a deployment job to report back a set of +variables, including the URL that was dynamically-generated by the external service. +GitLab supports [dotenv](https://github.com/bkeepers/dotenv) file as the format, +and expands the `environment:url` value with variables defined in the dotenv file. + +To use this feature, specify the +[`artifacts:reports:dotenv`](yaml/README.md#artifactsreportsdotenv) keyword in `.gitlab-ci.yml`. + +##### Example of setting dynamic environment URLs + +The following example shows a Review App that creates a new environment +per merge request. The `review` job is triggered by every push, and +creates or updates an environment named `review/your-branch-name`. +The environment URL is set to `$DYNAMIC_ENVIRONMENT_URL`: + +```yaml +review: + script: + - DYNAMIC_ENVIRONMENT_URL=$(deploy-script) # In script, get the environment URL. + - echo "DYNAMIC_ENVIRONMENT_URL=$DYNAMIC_ENVIRONMENT_URL" >> deploy.env # Add the value to a dotenv file. + artifacts: + reports: + dotenv: deploy.env # Report back dotenv file to rails. + environment: + name: review/$CI_COMMIT_REF_SLUG + url: $DYNAMIC_ENVIRONMENT_URL # and set the variable produced in script to `environment:url` + on_stop: stop_review + +stop_review: + script: + - ./teardown-environment + when: manual + environment: + name: review/$CI_COMMIT_REF_SLUG + action: stop +``` + +As soon as the `review` job finishes, GitLab updates the `review/your-branch-name` +environment's URL. +It parses the report artifact `deploy.env`, registers a list of variables as runtime-created, +uses it for expanding `environment:url: $DYNAMIC_ENVIRONMENT_URL` and sets it to the environment URL. +You can also specify a static part of the URL at `environment:url:`, such as +`https://$DYNAMIC_ENVIRONMENT_URL`. If the value of `DYNAMIC_ENVIRONMENT_URL` is +`123.awesome.com`, the final result will be `https://123.awesome.com`. + +The assigned URL for the `review/your-branch-name` environment is visible in the UI. +[See where the environment URL is displayed](#using-the-environment-url). + +> **Notes:** +> +> - `stop_review` doesn't generate a dotenv report artifact, so it won't recognize the `DYNAMIC_ENVIRONMENT_URL` variable. Therefore you should not set `environment:url:` in the `stop_review` job. +> - If the environment URL is not valid (for example, the URL is malformed), the system doesn't update the environment URL. + ### Configuring manual deployments Adding `when: manual` to an automatically executed job's configuration converts it to diff --git a/doc/ci/pipelines/index.md b/doc/ci/pipelines/index.md index a823793a995..092e7729ad3 100644 --- a/doc/ci/pipelines/index.md +++ b/doc/ci/pipelines/index.md @@ -1,4 +1,5 @@ --- +disqus_identifier: 'https://docs.gitlab.com/ee/ci/pipelines.html' type: reference --- diff --git a/doc/ci/pipelines/job_artifacts.md b/doc/ci/pipelines/job_artifacts.md index ef3a33e22ea..4cc6c2aa098 100644 --- a/doc/ci/pipelines/job_artifacts.md +++ b/doc/ci/pipelines/job_artifacts.md @@ -1,4 +1,5 @@ --- +disqus_identifier: 'https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html' type: reference, howto --- diff --git a/doc/ci/pipelines/schedules.md b/doc/ci/pipelines/schedules.md index 92cf1985d86..b9a2972dc89 100644 --- a/doc/ci/pipelines/schedules.md +++ b/doc/ci/pipelines/schedules.md @@ -1,4 +1,5 @@ --- +disqus_identifier: 'https://docs.gitlab.com/ee/user/project/pipelines/schedules.html' type: reference, howto --- diff --git a/doc/ci/pipelines/settings.md b/doc/ci/pipelines/settings.md index 53a529493d2..13b8f4ee307 100644 --- a/doc/ci/pipelines/settings.md +++ b/doc/ci/pipelines/settings.md @@ -1,4 +1,5 @@ --- +disqus_identifier: 'https://docs.gitlab.com/ee/user/project/pipelines/settings.html' type: reference, howto --- diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 9224d73b58b..1441526bc80 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -2264,6 +2264,25 @@ concatenated into a single file. Use a filename pattern (`junit: rspec-*.xml`), an array of filenames (`junit: [rspec-1.xml, rspec-2.xml, rspec-3.xml]`), or a combination thereof (`junit: [rspec.xml, test-results/TEST-*.xml]`). +##### `artifacts:reports:dotenv` + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/17066) in GitLab 12.9. Requires GitLab Runner 11.5 and later. + +The `dotenv` report collects a set of environment variables as artifacts. + +The collected variables are registered as runtime-created variables of the job, +which is useful to [set dynamic environment URLs after a job finishes](../environments.md#set-dynamic-environment-urls-after-a-job-finishes). +It is not available for download through the web interface. + +There are a couple of limitations on top of the [original dotenv rules](https://github.com/motdotla/dotenv#rules). + +- The variable key can contain only letters, digits and underscore ('_'). +- The size of dotenv file must be smaller than 5 kilobytes. +- The number of variables must be less than 10. +- It doesn't support variable substitution in the dotenv file itself. +- It doesn't support empty lines and comments (`#`) in dotenv file. +- It doesn't support quote escape, spaces in a quote, a new line expansion in a quote, in dotenv file. + ##### `artifacts:reports:codequality` **(STARTER)** > Introduced in GitLab 11.5. Requires GitLab Runner 11.5 and above. diff --git a/doc/user/incident_management/index.md b/doc/user/incident_management/index.md index 21dd3bf4d9a..3ddc6894653 100644 --- a/doc/user/incident_management/index.md +++ b/doc/user/incident_management/index.md @@ -39,6 +39,8 @@ To select your issue template for use within Incident Management: GitLab can react to the alerts that your applications and services may be triggering by automatically creating issues, and alerting developers via email. +The emails will be sent to [owners and maintainers](../permissions.md) of the project and will contain details on the alert as well as a link to see more information. + ### Prometheus alerts Prometheus alerts can be set up in both: |