Triggering new analysis from CI
We support analysis trigger from your continuous integration job. This is very simple to put in place and we use a generic method that can be adapted to most continuous integration environment such as jenkins or travis-ci.
Installing the CI tools
Our CI tools are distributed using PyPi. You can install them using the following command:
$ pip install code-inspector
Using the CI tools
Setting your API keys
In order to use the CI tool, you need to set up two environment variables that
identifies you are as user:
You can get these keys from the web interface, in your user preferences.
Important Note: these API keys identify you as a user and not as a project. Actions you can perform are limited by your user permissions.
Deprecation: early versions of code-inspector uses API key per-project. These keys are no longer working and the REST API that was using them is deprecated in favor of our new GraphQL API.
Trigger an Analysis
To trigger an analysis (and potentially get results from it), use the
If you pass the
-w flag to the
code-inspector binary, the program will produce
the results of the analysis, with the number of violations, duplicates as well
as the number of violations per language.
If you are working with a large project that takes time to analyze, you might
need to increase the timeout to get the analysis results using the
This flag defines the value of the timeout (in seconds) before getting the analysis results.
For example, the following line will trigger a new analysis, wait at most 20 minutes to get the analysis results and then print the results:
code-inspector-analyze -t 1200 -w -p "MY-AWESOME-PROJECT"
Compare a project status with another branch
Sometimes, you want to compare the status of your project with another
repository or just another branch. The program
is the one you want to use in that case.
The project compares your project against another codebase hosted
on another repository. You can specify a revision (flag
or specific branch (
--target-branch) to compare against.
You can also use your Github/Gitlab or Bitbucket credentials to checkout
the target repository (flag
You can use it as follow:
code-inspector-compare -t 1200 -w -p "MY-AWESOME-PROJECT" --url https://path/to/other/repository.git --target-branch development --kind Github
This will then start a comparison of
MY-AWESOME-PROJECT on code inspector
with the code on the repository
https://path/to/other/repository.git on the
To checkout the target repository, the Github credentials of the authenticated user are used.
Integration with GitLab Continuous Integration
The project is available on GitLab: https://gitlab.com/jhctechnology/code-quality/code-inspector
More information and contributing
For more information about the tool used for continuous integration, you can look at the related github project.