We recently had a company reach out to us asking if there was any way to audit code checked into their GitLab instance for a game they're working on. After some discussion, we explained the ideas behind CI/CD, and they fell in love with the concept.
While talking to them about what languages are being used and how their development process works, we quickly learned that no pre-made docker images would work, and that GitLab's Auto DevOps features were not a good fit for them. Because of this, we created some custom docker images with code-auditing tools they wanted. Read More
Although the custom Docker images work well at auditing code, they're pretty much useless if we don't have a good way of displaying the results to the programmer who checked in the code. Here's where GitLab's Code Quality widget really shines.
To combine all the results of all the code auditing jobs, we spin up a Docker image that has jq preinstalled. This tool can take in data, parse it as JSON, and output valid JSON (which is required for the Code Quality widget).
To do this, we exported data from each audit step as an artifact in our CI/CD .yml
files:
artifacts:
paths:
- audit1-output.json
Then we import the job artifacts in another job, which makes all our job artifacts reports available:needs:
- job: cppcheck
artifacts: true
- job: complexity
artifacts: true
Finally, we can concatenate the artifacts together, and run them through jq
to ensure we have valid json and export the concatenated file as gl-code-quality-report.json
, which is the required name for the code quality report.