From dac4c5bb5389b123a046d0e861443e124dc0e059 Mon Sep 17 00:00:00 2001 From: Katarzyna Kobierska <kkobierska@gmail.com> Date: Wed, 7 Sep 2016 12:19:36 +0200 Subject: [PATCH] Fix invalid curl command --- doc/api/ci/lint.md | 41 +------------------- lib/api/lint.rb | 9 +++-- spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 2 +- 3 files changed, 8 insertions(+), 44 deletions(-) diff --git a/doc/api/ci/lint.md b/doc/api/ci/lint.md index 89eafad740c..080bc2148f3 100644 --- a/doc/api/ci/lint.md +++ b/doc/api/ci/lint.md @@ -10,47 +10,10 @@ POST ci/lint | Attribute | Type | Required | Description | | ---------- | ------- | -------- | -------- | -| `content` | hash | yes | the .gitlab-ci.yaml content| +| `content` | string | yes | the .gitlab-ci.yaml content| ```bash -curl --request POST "https://gitlab.example.com/api/v3/ci/lint?content={ - image: "ruby:2.1", - services: ["postgres"], - before_script: ["gem install bundler", "bundle install", "bundle exec rake db:create"], - variables: {"DB_NAME": "postgres"}, - types: ["test", "deploy", "notify"], - rspec: { - script: "rake spec", - tags: ["ruby", "postgres"], - only: ["branches"] - }, - spinach: { - script: "rake spinach", - allow_failure: true, - tags: ["ruby", "mysql"], - except: ["tags"] - }, - staging: { - variables: {KEY1: "value1", KEY2: "value2"}, - script: "cap deploy stating", - type: "deploy", - tags: ["ruby", "mysql"], - except: ["stable"] - }, - production: { - variables: {DB_NAME: "mysql"}, - type: "deploy", - script: ["cap deploy production", "cap notify"], - tags: ["ruby", "mysql"], - only: ["master", "/^deploy-.*$/"] - }, - dockerhub: { - type: "notify", - script: "curl http://dockerhub/URL", - tags: ["ruby", "postgres"], - only: ["branches"] - } -}" +curl -H "Content-Type: application/json" --request POST https://gitlab.example.com/api/v3/ci/lint -d '{"content": "{ \"image\": \"ruby:2.1\", \"services\": [\"postgres\"], \"before_script\": [\"gem install bundler\", \"bundle install\", \"bundle exec rake db:create\"], \"variables\": {\"DB_NAME\": \"postgres\"}, \"types\": [\"test\", \"deploy\", \"notify\"], \"rspec\": { \"script\": \"rake spec\", \"tags\": [\"ruby\", \"postgres\"], \"only\": [\"branches\"]}}"}' ``` Be sure to copy paste the exact contents of `.gitlab-ci.yml` as YAML is very picky about indentation and spaces. diff --git a/lib/api/lint.rb b/lib/api/lint.rb index 0af132803ba..8a7ced2d34d 100644 --- a/lib/api/lint.rb +++ b/lib/api/lint.rb @@ -1,11 +1,12 @@ module API class Lint < Grape::API - desc 'Validation of .gitlab-ci.yml content' - params do - requires :content, type: String, desc: 'Content of .gitlab-ci.yml' - end namespace :ci do + desc 'Validation of .gitlab-ci.yml content' + params do + requires :content, type: String, desc: 'Content of .gitlab-ci.yml' + end + post '/lint' do error = Ci::GitlabCiYamlProcessor.validation_message(params[:content]) diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 43631070024..af192664b33 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -1270,7 +1270,7 @@ EOT end end - context "when YMAL content is empty" do + context "when YAML content is empty" do it "returns an error about missing content" do expect(GitlabCiYamlProcessor.validation_message('')) .to eq "Please provide content of .gitlab-ci.yml" -- GitLab