mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
feat(bitbucket-pipelines): support bitbucket pipe renovations (#11859)
This commit is contained in:
parent
27812e9c1f
commit
2d2a599b91
6 changed files with 142 additions and 0 deletions
|
@ -5,6 +5,7 @@ import * as azurePipelines from './azure-pipelines';
|
|||
import * as batect from './batect';
|
||||
import * as batectWrapper from './batect-wrapper';
|
||||
import * as bazel from './bazel';
|
||||
import * as bitbucketPipelines from './bitbucket-pipelines';
|
||||
import * as buildkite from './buildkite';
|
||||
import * as bundler from './bundler';
|
||||
import * as cake from './cake';
|
||||
|
@ -72,6 +73,7 @@ api.set('azure-pipelines', azurePipelines);
|
|||
api.set('batect', batect);
|
||||
api.set('batect-wrapper', batectWrapper);
|
||||
api.set('bazel', bazel);
|
||||
api.set('bitbucket-pipelines', bitbucketPipelines);
|
||||
api.set('buildkite', buildkite);
|
||||
api.set('bundler', bundler);
|
||||
api.set('cake', cake);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
image: node:10.15.1
|
||||
|
||||
pipelines:
|
||||
default:
|
||||
- step:
|
||||
name: Build and Test
|
||||
image: node:10.15.2
|
||||
script:
|
||||
- npm install
|
||||
- npm test
|
||||
- npm run dist
|
||||
artifacts:
|
||||
- dist/**
|
||||
- step:
|
||||
name: Deploy
|
||||
deployment: production
|
||||
script:
|
||||
- pipe: atlassian/aws-s3-deploy:0.2.1
|
||||
variables:
|
||||
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
|
||||
AWS_DEFAULT_REGION: "us-east-1"
|
||||
S3_BUCKET: "my-bucket-name"
|
||||
LOCAL_PATH: "dist"
|
45
lib/manager/bitbucket-pipelines/extract.spec.ts
Normal file
45
lib/manager/bitbucket-pipelines/extract.spec.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { loadFixture } from '../../../test/util';
|
||||
import { extractPackageFile } from './extract';
|
||||
|
||||
const bitbucketPipelinesYAML = loadFixture('bitbucket-pipelines.yaml');
|
||||
|
||||
describe('manager/bitbucket-pipelines/extract', () => {
|
||||
describe('extractPackageFile()', () => {
|
||||
it('returns null for empty', () => {
|
||||
expect(extractPackageFile('nothing here')).toBeNull();
|
||||
});
|
||||
|
||||
it('extracts dependencies', () => {
|
||||
const res = extractPackageFile(bitbucketPipelinesYAML);
|
||||
expect(res.deps).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
|
||||
"currentDigest": undefined,
|
||||
"currentValue": "10.15.1",
|
||||
"datasource": "docker",
|
||||
"depName": "node",
|
||||
"depType": "docker",
|
||||
"replaceString": "node:10.15.1",
|
||||
},
|
||||
Object {
|
||||
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
|
||||
"currentDigest": undefined,
|
||||
"currentValue": "10.15.2",
|
||||
"datasource": "docker",
|
||||
"depName": "node",
|
||||
"depType": "docker",
|
||||
"replaceString": "node:10.15.2",
|
||||
},
|
||||
Object {
|
||||
"currentValue": "0.2.1",
|
||||
"datasource": "bitbucket-tags",
|
||||
"depName": "atlassian/aws-s3-deploy",
|
||||
"depType": "bitbucket-tags",
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(res.deps).toHaveLength(3);
|
||||
});
|
||||
});
|
||||
});
|
61
lib/manager/bitbucket-pipelines/extract.ts
Normal file
61
lib/manager/bitbucket-pipelines/extract.ts
Normal file
|
@ -0,0 +1,61 @@
|
|||
import { logger } from '../../logger';
|
||||
import { regEx } from '../../util/regex';
|
||||
import { getDep } from '../dockerfile/extract';
|
||||
import type { PackageDependency, PackageFile } from '../types';
|
||||
|
||||
const pipeRegex = regEx(`^\\s*-\\s?pipe:\\s*'?"?([^\\s'"]+)'?"?\\s*$`);
|
||||
const dockerImageRegex = regEx(`^\\s*-?\\s?image:\\s*'?"?([^\\s'"]+)'?"?\\s*$`);
|
||||
|
||||
export function extractPackageFile(content: string): PackageFile | null {
|
||||
const deps: PackageDependency[] = [];
|
||||
|
||||
try {
|
||||
const lines = content.split('\n');
|
||||
for (const line of lines) {
|
||||
const pipeMatch = pipeRegex.exec(line);
|
||||
if (pipeMatch) {
|
||||
const pipe = pipeMatch[1];
|
||||
const [depName, currentValue] = pipe.split(':');
|
||||
|
||||
const dep: PackageDependency = {
|
||||
depName,
|
||||
currentValue,
|
||||
datasource: 'bitbucket-tags',
|
||||
};
|
||||
|
||||
logger.trace(
|
||||
{
|
||||
depName: dep.depName,
|
||||
currentValue: dep.currentValue,
|
||||
},
|
||||
'Bitbucket pipe'
|
||||
);
|
||||
dep.depType = 'bitbucket-tags';
|
||||
deps.push(dep);
|
||||
}
|
||||
|
||||
const dockerImageMatch = dockerImageRegex.exec(line);
|
||||
if (dockerImageMatch) {
|
||||
const currentFrom = dockerImageMatch[1];
|
||||
const dep = getDep(currentFrom);
|
||||
|
||||
logger.trace(
|
||||
{
|
||||
depName: dep.depName,
|
||||
currentValue: dep.currentValue,
|
||||
currentDigest: dep.currentDigest,
|
||||
},
|
||||
'Docker image'
|
||||
);
|
||||
dep.depType = 'docker';
|
||||
deps.push(dep);
|
||||
}
|
||||
}
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
logger.warn({ err }, 'Error extracting Bitbucket Pipes dependencies');
|
||||
}
|
||||
if (!deps.length) {
|
||||
return null;
|
||||
}
|
||||
return { deps };
|
||||
}
|
7
lib/manager/bitbucket-pipelines/index.ts
Normal file
7
lib/manager/bitbucket-pipelines/index.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { extractPackageFile } from './extract';
|
||||
|
||||
export { extractPackageFile };
|
||||
|
||||
export const defaultConfig = {
|
||||
fileMatch: ['(^|/)\\.bitbucket-pipelines\\.yaml$'],
|
||||
};
|
3
lib/manager/bitbucket-pipelines/readme.md
Normal file
3
lib/manager/bitbucket-pipelines/readme.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Extracts dependencies from Bitbucket Pipelines config files.
|
||||
|
||||
If you need to change the versioning format, read the [versioning](https://docs.renovatebot.com/modules/versioning/) documentation to learn more.
|
Loading…
Reference in a new issue