Skip to content

Add json api endpoint that provides CI linting

What does this MR do?

Provides a json formatted API endpoint for CI linting.

Example Invalid Config Response

curl 'http://host.docker.internal:3000/root/retries/-/ci/lint.json' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' -H 'Upgrade-Insecure-Requests: 1' -H 'Origin: http://host.docker.internal:3000' -H 'Content-Type: application/x-www-form-urlencoded' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' -H 'Referer: http://host.docker.internal:3000/root/retries/-/ci/lint' -H 'Accept-Language: en-US,en;q=0.9' -H 'Cookie: ' --compressed --insecure | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   219  100    71  100   148    268    560 --:--:-- --:--:-- --:--:--   829
{
   "config" : null,
   "errors" : [
      "Invalid configuration format"
   ],
   "valid" : false
}

Example Valid Config Response

 curl 'http://localhost:3000/root/when-always-with-no-workflow-rules-2/-/ci/lint.json' \
  -H 'Connection: keep-alive' \
  -H 'Cache-Control: max-age=0' \
  -H 'Upgrade-Insecure-Requests: 1' \
  -H 'Origin: http://localhost:3000' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36' \
  -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'Sec-Fetch-Mode: navigate' \
  -H 'Sec-Fetch-User: ?1' \
  -H 'Sec-Fetch-Dest: document' \
  -H 'Referer: http://localhost:3000/root/when-always-with-no-workflow-rules-2/-/ci/lint.json' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Cookie: ' \
  --compressed | json_pp
{
   "jobs" : [
      {
         "allow_failure" : false,
         "except" : null,
         "when" : "on_success",
         "before_script" : [],
         "stage" : "test",
         "script" : [
            "echo"
         ],
         "only" : null,
         "name" : "job",
         "environment" : null,
         "tag_list" : [],
         "after_script" : []
      }
   ],
   "valid" : true,
   "warnings" : [],
   "errors" : []
}

See Issue: #196032 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Allison Browne

Merge request reports