Skip to content

Commit

Permalink
fix(gitlabci): filter out !reference tags in gitlabci-include (#9741)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeijn committed Apr 28, 2021
1 parent 135875d commit 038f52c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/manager/gitlabci-include/__fixtures__/gitlab-ci.1.yaml
Expand Up @@ -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]
5 changes: 4 additions & 1 deletion lib/manager/gitlabci-include/extract.ts
Expand Up @@ -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: {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion 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.
Expand Down

0 comments on commit 038f52c

Please sign in to comment.