Commit 28f157b8 authored by Aidin Abedi's avatar Aidin Abedi Committed by Grzegorz Bizon

Add CI variable to provide GitLab base URL

parent 9de12ecd
...@@ -1932,6 +1932,7 @@ class Project < ApplicationRecord ...@@ -1932,6 +1932,7 @@ class Project < ApplicationRecord
Gitlab::Ci::Variables::Collection.new Gitlab::Ci::Variables::Collection.new
.append(key: 'CI', value: 'true') .append(key: 'CI', value: 'true')
.append(key: 'GITLAB_CI', value: 'true') .append(key: 'GITLAB_CI', value: 'true')
.append(key: 'CI_SERVER_URL', value: Gitlab.config.gitlab.url)
.append(key: 'CI_SERVER_HOST', value: Gitlab.config.gitlab.host) .append(key: 'CI_SERVER_HOST', value: Gitlab.config.gitlab.host)
.append(key: 'CI_SERVER_NAME', value: 'GitLab') .append(key: 'CI_SERVER_NAME', value: 'GitLab')
.append(key: 'CI_SERVER_VERSION', value: Gitlab::VERSION) .append(key: 'CI_SERVER_VERSION', value: Gitlab::VERSION)
......
---
title: Add CI variable to provide GitLab base URL
merge_request: 22327
author: Aidin Abedi
type: added
...@@ -290,6 +290,7 @@ export CI_RUNNER_ID="10" ...@@ -290,6 +290,7 @@ export CI_RUNNER_ID="10"
export CI_RUNNER_DESCRIPTION="my runner" export CI_RUNNER_DESCRIPTION="my runner"
export CI_RUNNER_TAGS="docker, linux" export CI_RUNNER_TAGS="docker, linux"
export CI_SERVER="yes" export CI_SERVER="yes"
export CI_SERVER_URL="https://example.com"
export CI_SERVER_HOST="example.com" export CI_SERVER_HOST="example.com"
export CI_SERVER_NAME="GitLab" export CI_SERVER_NAME="GitLab"
export CI_SERVER_REVISION="70606bf" export CI_SERVER_REVISION="70606bf"
...@@ -673,6 +674,8 @@ Running on runner-8a2f473d-project-1796893-concurrent-0 via runner-8a2f473d-mach ...@@ -673,6 +674,8 @@ Running on runner-8a2f473d-project-1796893-concurrent-0 via runner-8a2f473d-mach
++ CI_PROJECT_DIR=/builds/gitlab-examples/ci-debug-trace ++ CI_PROJECT_DIR=/builds/gitlab-examples/ci-debug-trace
++ export CI_SERVER=yes ++ export CI_SERVER=yes
++ CI_SERVER=yes ++ CI_SERVER=yes
++ export CI_SERVER_URL=https://example.com:3000
++ CI_SERVER_URL=https://example.com:3000
++ export 'CI_SERVER_HOST=example.com' ++ export 'CI_SERVER_HOST=example.com'
++ CI_SERVER_HOST='example.com' ++ CI_SERVER_HOST='example.com'
++ export 'CI_SERVER_NAME=GitLab CI' ++ export 'CI_SERVER_NAME=GitLab CI'
...@@ -709,6 +712,8 @@ Running on runner-8a2f473d-project-1796893-concurrent-0 via runner-8a2f473d-mach ...@@ -709,6 +712,8 @@ Running on runner-8a2f473d-project-1796893-concurrent-0 via runner-8a2f473d-mach
++ CI_JOB_NAME=debug_trace ++ CI_JOB_NAME=debug_trace
++ export CI_JOB_STAGE=test ++ export CI_JOB_STAGE=test
++ CI_JOB_STAGE=test ++ CI_JOB_STAGE=test
++ export CI_SERVER_URL=https://example.com:3000
++ CI_SERVER_URL=https://example.com:3000
++ export CI_SERVER_HOST=example.com ++ export CI_SERVER_HOST=example.com
++ CI_SERVER_HOST=example.com ++ CI_SERVER_HOST=example.com
++ export CI_SERVER_NAME=GitLab ++ export CI_SERVER_NAME=GitLab
......
...@@ -112,6 +112,7 @@ future GitLab releases.** ...@@ -112,6 +112,7 @@ future GitLab releases.**
| `CI_RUNNER_TAGS` | 8.10 | 0.5 | The defined runner tags | | `CI_RUNNER_TAGS` | 8.10 | 0.5 | The defined runner tags |
| `CI_RUNNER_VERSION` | all | 10.6 | GitLab Runner version that is executing the current job | | `CI_RUNNER_VERSION` | all | 10.6 | GitLab Runner version that is executing the current job |
| `CI_SERVER` | all | all | Mark that job is executed in CI environment | | `CI_SERVER` | all | all | Mark that job is executed in CI environment |
| `CI_SERVER_URL` | 12.7 | all | The base URL of the GitLab instance, including protocol and port (like `https://gitlab.example.com:8080`) |
| `CI_SERVER_HOST` | 12.1 | all | Host component of the GitLab instance URL, without protocol and port (like `gitlab.example.com`) | | `CI_SERVER_HOST` | 12.1 | all | Host component of the GitLab instance URL, without protocol and port (like `gitlab.example.com`) |
| `CI_SERVER_NAME` | all | all | The name of CI server that is used to coordinate jobs | | `CI_SERVER_NAME` | all | all | The name of CI server that is used to coordinate jobs |
| `CI_SERVER_REVISION` | all | all | GitLab revision that is used to schedule jobs | | `CI_SERVER_REVISION` | all | all | GitLab revision that is used to schedule jobs |
......
...@@ -2359,6 +2359,7 @@ describe Ci::Build do ...@@ -2359,6 +2359,7 @@ describe Ci::Build do
{ key: 'CI_BUILD_STAGE', value: 'test', public: true, masked: false }, { key: 'CI_BUILD_STAGE', value: 'test', public: true, masked: false },
{ key: 'CI', value: 'true', public: true, masked: false }, { key: 'CI', value: 'true', public: true, masked: false },
{ key: 'GITLAB_CI', value: 'true', public: true, masked: false }, { key: 'GITLAB_CI', value: 'true', public: true, masked: false },
{ key: 'CI_SERVER_URL', value: Gitlab.config.gitlab.url, public: true, masked: false },
{ key: 'CI_SERVER_HOST', value: Gitlab.config.gitlab.host, public: true, masked: false }, { key: 'CI_SERVER_HOST', value: Gitlab.config.gitlab.host, public: true, masked: false },
{ key: 'CI_SERVER_NAME', value: 'GitLab', public: true, masked: false }, { key: 'CI_SERVER_NAME', value: 'GitLab', public: true, masked: false },
{ key: 'CI_SERVER_VERSION', value: Gitlab::VERSION, public: true, masked: false }, { key: 'CI_SERVER_VERSION', value: Gitlab::VERSION, public: true, masked: false },
......
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