api

[!NOTE] api url: http(s)://sample.klocwork.com:443/review/api reference:

Klocwork Static Code Analysis Web API Reference

to access Web API send a POST request to http://sample.klocwork.com/review/api with the following parameters:

  • user* Klocwork user name

  • ltoken kwauth login token

  • action* action name

    • builds: retrieve the list of builds for a project.

    • example: curl --data "action=builds&user=myself&project=project_name" http://sample.klocwork.com/review/api

      • project* : project name

      • username : username

list all projects

$ username='account'
$ ltoken='abc123**********************************************************'
$ url='https://sample.klocwork.com:8080'
$ curl -skg \
       --data "action=projects&user=${username}&ltoken=${ltoken}" \
       "${url}/review/api" |
  jq -r .id

list builds info from project

ltoek is got from ${KLOCWORK_LTOKEN} file

reference:

api additional header : -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8"

  • via api

    $ curl --data "action=builds&user=<user_account>&ltoken=<ltoken>&project=<projct_name>" http://sample.klocwork.com/review/api
    • i.e.:

      $ curl --data "action=builds&user=marslo&ltoken=abcd1234****&project=marslo-kw" \
             https://sample.klocwork.com:443/review/api
      {"id":3,"name":"build_3","date":1619437882164,"keepit":false}
      {"id":2,"name":"build_2","date":1619436216567,"keepit":false}
      {"id":1,"name":"build_1","date":1619434698145,"keepit":false}
  • via kwadmin

    $ kwadmin --url https://sample.klocwork.com:443 list-builds marslo-kw
    build_1
    build_2
    build_3
    • list project config files

      $ kwadmin --url https://sample.klocwork.com:443 list-config-files marslo-kw
      analysis_profile.pconf (Problems Configuration)
      metrics_default.mconf (Metrics Thresholds)

query only new issues

search

retrieve the list of detected issues.

  • example: curl --data "action=search&user=myself&project=my_project&query=file:MyFile.c" http://sample.klocwork.com/review/api

    • project* : project name

    • query : search query, such as narrowing by file (for example, 'file:MyFile.c')

    • view : view name

    • limit : search result limit

    • summary : include summary record to output stream

Searching in Klocwork Static Code Analysis: Searching in Klocwork Static Code Analysis

NOTE: You can only search by one build at a time. Other acceptable syntax:

  • build:'123' - searches for build which contains substring '123'

  • build:+123 - searches for build with name 123

  • build:+'123string' - searches for build with name equal to '123string'

$ ltoken='abcd1234*****'
$ username='marslo'
$ project='marslo-kw'
$ query='build:build_3 state:New'
$ url='https://sample.klocwork.com:443'
$ curl --data "action=search&user=${username}&ltoken=${ltoken}&project=${project}&query=${query}" \
       ${url}/review/api |
       jq --raw-output .

actions

[!NOTE|label:references:]

server

access

project

builds

issue

report

Last updated