diff --git a/lib/manager/gitlabci-include/__fixtures__/gitlab-ci.1.yaml b/lib/manager/gitlabci-include/__fixtures__/gitlab-ci.1.yaml index 49b6ce2def6b9f..9f57e8ee9c8018 100644 --- a/lib/manager/gitlabci-include/__fixtures__/gitlab-ci.1.yaml +++ b/lib/manager/gitlabci-include/__fixtures__/gitlab-ci.1.yaml @@ -7,3 +7,7 @@ include: ref: master - {"project":"mikebryant/include-source-example3", "file": "/template.yaml",} - {} + +script: +- !reference [.setup, script] +- !reference [arbitrary job name with space and no starting dot, nested1, nested2, nested3] diff --git a/lib/manager/gitlabci-include/extract.ts b/lib/manager/gitlabci-include/extract.ts index b3ba608b47ea04..654f5db8efafaf 100644 --- a/lib/manager/gitlabci-include/extract.ts +++ b/lib/manager/gitlabci-include/extract.ts @@ -3,6 +3,7 @@ import yaml from 'js-yaml'; import * as datasourceGitlabTags from '../../datasource/gitlab-tags'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; +import { replaceReferenceTags } from '../gitlabci/utils'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; function extractDepFromIncludeFile(includeObj: { @@ -31,7 +32,9 @@ export function extractPackageFile( const deps: PackageDependency[] = []; try { // TODO: fix me (#9610) - const doc = yaml.safeLoad(content, { json: true }) as any; + const doc = yaml.safeLoad(replaceReferenceTags(content), { + json: true, + }) as any; if (doc?.include && is.array(doc.include)) { for (const includeObj of doc.include) { if (includeObj.file && includeObj.project) { diff --git a/lib/manager/gitlabci/utils.ts b/lib/manager/gitlabci/utils.ts index 1cb036baefd756..28124d3179d82e 100644 --- a/lib/manager/gitlabci/utils.ts +++ b/lib/manager/gitlabci/utils.ts @@ -1,4 +1,4 @@ -const re = /!reference \[\.\w+?(?:, \w+?)\]/g; +const re = /!reference \[(.*?)\]/g; /** * Replaces GitLab reference tags before parsing, because our yaml parser cannot process them anyway.