summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-04-25 21:42:46 +0900
committerKamil TrzciƄski <ayufan@ayufan.eu>2018-05-03 10:48:33 +0200
commit8192cd70ed109e9c0b7f4670234af11f206694d4 (patch)
tree514e513ae34d23baad69040478c8442a4e4bbead
parent332d3d0ef5215c2a363c99c90fb7d31af90a0a5a (diff)
downloadgitlab-ce-8192cd70ed109e9c0b7f4670234af11f206694d4.tar.gz
Expose CI_PIPELINE_IID_PER_PROJECT variable
-rw-r--r--app/models/ci/pipeline.rb3
-rw-r--r--doc/ci/variables/README.md1
2 files changed, 3 insertions, 1 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 65b282ecec4..3cdb86e7b55 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -14,7 +14,7 @@ module Ci
belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline'
belongs_to :pipeline_schedule, class_name: 'Ci::PipelineSchedule'
- has_internal_id :iid, scope: :project, init: ->(s) { s&.project&.pipelines.maximum(:iid) }
+ has_internal_id :iid_per_project, scope: :project, init: ->(s) { s&.project&.pipelines.count }
has_many :stages
has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
@@ -492,6 +492,7 @@ module Ci
def predefined_variables
Gitlab::Ci::Variables::Collection.new
.append(key: 'CI_PIPELINE_ID', value: id.to_s)
+ .append(key: 'CI_PIPELINE_IID_PER_PROJECT', value: iid_per_project.to_s)
.append(key: 'CI_CONFIG_PATH', value: ci_yaml_file_path)
.append(key: 'CI_PIPELINE_SOURCE', value: source.to_s)
end
diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md
index 38a988f4507..8eb0fc5ea49 100644
--- a/doc/ci/variables/README.md
+++ b/doc/ci/variables/README.md
@@ -60,6 +60,7 @@ future GitLab releases.**
| **CI_RUNNER_REVISION** | all | 10.6 | GitLab Runner revision that is executing the current job |
| **CI_RUNNER_EXECUTABLE_ARCH** | all | 10.6 | The OS/architecture of the GitLab Runner executable (note that this is not necessarily the same as the environment of the executor) |
| **CI_PIPELINE_ID** | 8.10 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally |
+| **CI_PIPELINE_IID_PER_PROJECT** | 10.8 | all | The unique id of the current pipeline that GitLab CI uses internally (Incremented per project) |
| **CI_PIPELINE_TRIGGERED** | all | all | The flag to indicate that job was [triggered] |
| **CI_PIPELINE_SOURCE** | 10.0 | all | Indicates how the pipeline was triggered. Possible options are: `push`, `web`, `trigger`, `schedule`, `api`, and `pipeline`. For pipelines created before GitLab 9.5, this will show as `unknown` |
| **CI_PROJECT_DIR** | all | all | The full path where the repository is cloned and where the job is run |