Improve branch selection logic for docs-lint hugo job
What does this MR do?
Two fixes for the docs-lint hugo
CI job. This job needs to checkout a copy of the Docs website that matches the version of the MR or branch that a change to Omnibus is targeting, and it was missing handling for two scenarios:
-
If Omnibus cuts a release branch and then needs to merge a docs change to it before the Docs site's corresponding release branch exists, we need to fallback to the Docs site's
main
branch for the Hugo build job. If we attempt to checkout a non-existent docs site branch, the job incorrectly fails.This can happen shortly before a release since the Docs site release branch is cut on release day, but other projects cut their branches earlier.
Similar fix in
gitlab
: gitlab!204420 (merged) -
Branch selection logic was also wrong for commits that run outside of MRs, like a direct push to a branch with a security fix, which happened here. This was because the original code only checked against
CI_MERGE_REQUEST_TARGET_BRANCH_NAME
, which is only available in merge request pipelines. When the job ran for other pipeline types (likePROTECTED_TEST_PIPELINE
in that case), this variable was empty, so the branch detection logic failed and it always defaulted to the (incorrect)main
docs branch.Similar fix in
gitlab
: gitlab!200118 (merged)
Example jobs
To test the different conditions I adjusted the target branch on this MR, then ran the pipeline:
MR target branch | Expected Docs branch | Example |
---|---|---|
18-3-stable |
18.3 |
https://gitlab.com/gitlab-org/omnibus-gitlab/-/jobs/11553688558 |
18-4-stable |
main (docs 18.4 branch did not exist yet) |
https://gitlab.com/gitlab-org/omnibus-gitlab/-/jobs/11407274094 |
main |
main |
https://gitlab.com/gitlab-org/omnibus-gitlab/-/jobs/11407915435 |
Related issues
gitlab-org/technical-writing/docs-gitlab-com#450 (closed)
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion.
Required
-
MR title and description are up to date, accurate, and descriptive. -
MR targeting the appropriate branch. -
Latest Merge Result pipeline is green. -
When ready for review, MR is labeled workflowready for review per the Distribution MR workflow.
For GitLab team members
If you don't have access to this, the reviewer should trigger these jobs for you during the review process.
-
The manual Trigger:ee-package
jobs have a green pipeline running against latest commit. -
If config/software
orconfig/patches
directories are changed, make sure thebuild-package-on-all-os
job within theTrigger:ee-package
downstream pipeline succeeded. -
If you are changing anything SSL related, then the Trigger:package:fips
manual job within theTrigger:ee-package
downstream pipeline must succeed. -
If CI configuration is changed, the branch must be pushed to dev.gitlab.org
to confirm regular branch builds aren't broken.
Expected (please provide an explanation if not completing)
-
Test plan indicating conditions for success has been posted and passes. -
Documentation created/updated. -
Tests added. -
Integration tests added to GitLab QA. -
Equivalent MR/issue for the GitLab Chart opened. -
Validate potential values for new configuration settings. Formats such as integer 10
, duration10s
, URIscheme://user:passwd@host:port
may require quotation or other special handling when rendered in a template and written to a configuration file.