File: lint.rb

package info (click to toggle)
ruby-gitlab 5.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,660 kB
  • sloc: ruby: 12,582; makefile: 7; sh: 4
file content (19 lines) | stat: -rw-r--r-- 879 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class Gitlab::Client
  # Defines methods related to lint/validations.
  # @see https://docs.gitlab.com/ce/api/lint.html
  module Lint
    # Checks if your .gitlab-ci.yml file is valid.
    #
    # @example
    #   Gitlab.validate_gitlab_ci_yml("{ \"image\": \"ruby:2.6\", \"services\": [\"postgres\"], \"before_script\": [\"bundle install\", \"bundle exec rake db:create\"], \"variables\": {\"DB_NAME\": \"postgres\"}, \"types\": [\"test\", \"deploy\", \"notify\"], \"rspec\": { \"script\": \"rake spec\", \"tags\": [\"ruby\", \"postgres\"], \"only\": [\"branches\"]}}")
    #
    # @param  [String] content the .gitlab-ci.yaml content.
    # @return <Gitlab::ObjectifiedHash> Returns information about validity of the yml.
    def validate_gitlab_ci_yml(content)
      body = { content: content }
      post('/lint', body: body)
    end
  end
end