Commit bf20a3aa authored by Kamil Trzcinski's avatar Kamil Trzcinski

Improve after code review

parent 35d0b9ff
......@@ -53,7 +53,7 @@ module Ci
schedule: 4,
api: 5,
external: 6,
dependent_pipeline: 7
pipeline: 7
}
state_machine :status, initial: :created do
......
......@@ -15,8 +15,8 @@ module Ci
return unless trigger.project == project
trigger_request = trigger.trigger_requests.create(variables: params[:variables])
pipeline = Ci::CreatePipelineService.new(project, trigger.owner, ref: params[:ref]).
execute(:trigger, ignore_skip_ci: true, trigger_request: trigger_request)
pipeline = Ci::CreatePipelineService.new(project, trigger.owner, ref: params[:ref])
.execute(:trigger, ignore_skip_ci: true, trigger_request: trigger_request)
if pipeline.persisted?
success(pipeline: pipeline)
......@@ -33,7 +33,7 @@ module Ci
return error("400 Variables not supported", 400) if params[:variables].any?
pipeline = Ci::CreatePipelineService.new(project, job.user, ref: params[:ref]).
execute(:dependent_pipeline, ignore_skip_ci: true) do |pipeline|
execute(:pipeline, ignore_skip_ci: true) do |pipeline|
job.sourced_pipelines.create!(pipeline: pipeline)
end
......@@ -47,13 +47,13 @@ module Ci
def trigger_from_token
return @trigger if defined?(@trigger)
@trigger ||= Ci::Trigger.find_by_token(params[:token].to_s)
@trigger = Ci::Trigger.find_by_token(params[:token].to_s)
end
def job_from_token
return @job if defined?(@job)
@job ||= Ci::Build.find_by_token(params[:token].to_s)
@job = Ci::Build.find_by_token(params[:token].to_s)
end
end
end
......@@ -168,7 +168,7 @@ Since GitLab 9.3 you can trigger a new pipeline using a CI_JOB_TOKEN.
This method currently doesn't support Variables.
The support for them will be included in 9.4 of GitLab.
This way of triggering does create a dependent pipeline relation on Pipeline Graph page.
This way of triggering creates a dependent pipeline relation visible on the Pipeline Graph.
```yaml
build_docs:
......@@ -179,7 +179,7 @@ build_docs:
- tags
```
Pipelines triggered that way do expose a special variable: `CI_PIPELINE_SOURCE=dependent_pipeline`.
Pipelines triggered that way do expose a special variable: `CI_PIPELINE_SOURCE=pipeline`.
### Making use of trigger variables
......
......@@ -53,7 +53,7 @@ future GitLab releases.**
| **CI_RUNNER_ID** | 8.10 | 0.5 | The unique id of runner being used |
| **CI_RUNNER_TAGS** | 8.10 | 0.5 | The defined runner tags |
| **CI_PIPELINE_ID** | 8.10 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally |
| **CI_PIPELINE_SOURCE** | 9.3 | all | The variable indicates how the pipeline was triggered, possible options are: push, web, trigger, schedule, api, dependent_pipeline |
| **CI_PIPELINE_SOURCE** | 9.3 | all | The variable indicates how the pipeline was triggered, possible options are: push, web, trigger, schedule, api, pipeline |
| **CI_PIPELINE_TRIGGERED** | all | all | The flag to indicate that job was [triggered] |
| **CI_PROJECT_DIR** | all | all | The full path where the repository is cloned and where the job is run |
| **CI_PROJECT_ID** | all | all | The unique id of the current project that GitLab CI uses internally |
......
......@@ -145,12 +145,12 @@ describe API::Triggers do
context 'for related user' do
let(:other_user) { create(:user) }
context 'with reported permissions' do
context 'with reporter permissions' do
before do
project.add_reporter(other_user)
end
it 'forbidds pipeline creation' do
it 'forbids to create a pipeline' do
subject
expect(response).to have_http_status(400)
......@@ -167,7 +167,7 @@ describe API::Triggers do
expect { subject }.to change(Ci::Pipeline, :count)
expect(response).to have_http_status(201)
expect(Ci::Pipeline.last.source).to eq('dependent_pipeline')
expect(Ci::Pipeline.last.source).to eq('pipeline')
expect(Ci::Pipeline.last.triggered_by_pipeline).not_to be_nil
end
......@@ -176,10 +176,11 @@ describe API::Triggers do
other_job.success
end
it 'creates a new pipeline' do
it 'does not create a pipeline' do
subject
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('400 Job has to be running')
end
end
......@@ -189,7 +190,7 @@ describe API::Triggers do
variables: { 'KEY' => 'VALUE' } }
end
it 'forbidds pipeline creation' do
it 'forbids to create a pipeline' do
subject
expect(response).to have_http_status(400)
......
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