Licenses count always 0 when landing on pipeline page
Summary
When landing on a pipeline page, the licenses count is always 0
even when licenses have been detected in the pipeline.
Steps to reproduce
In a project where License Scanning is configured, go to a pipeline page. The licenses count is 0
when you land on that page.
Example Project
Any project where License Scanning is configured.
Example: https://gitlab.com/gitlab-org/security-products/tests/php-composer/-/pipelines/742515529/builds
- It shows
Licenses 0
when landing on theJobs
tab of the pipeline. - If you select to the
Licenses
tab, then it showsLicenses 4
. - If you select
Jobs
again, then it still showsLicenses 4
. - But then if you refresh the page (
Jobs
tab), then it showsLicenses 0
.
What is the current bug behavior?
The licenses count is 0
when landing on the pipeline, except when Licenses
is the active tab.
What is the expected correct behavior?
The licenses count is correct when landing on the pipeline page, even if the active tab isn't Licenses
.
Relevant logs and/or screenshots
First, land on the pipeline page:
Then, select the Licenses
tab:
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Implementation Plan
- In
ee/app/helpers/ee/projects/pipeline_helper.rb
add something like
def js_pipeline_tabs_data(project, pipeline, user)
super.merge(
...
license_scan_count: license_scan_count(pipeline)
)
end
def license_scan_count(pipeline)
if project.licensed_feature_available?(:license_scanning)
::Gitlab::LicenseScanning.scanner_for_pipeline(pipeline).report.licenses.count
end
end
- In
app/assets/javascripts/pipelines/pipeline_tabs.js
const {
...
licenseScanCount
} = dataset
...
provide: {
...
licenseScanCount
}
- In
ee/app/assets/javascripts/pipelines/components/pipeline_tabs.vue
inject: {
...
licenseScanCount
}
and set initial count to what we get from backend and rails template injection
data() {
return {
licenseCount: this.licenseScanCount,
};
},
- Update unit tests
/cc @farias-gl