Skip to content
Snippets Groups Projects
Unverified Commit bcaaee50 authored by Maxim Danilov's avatar Maxim Danilov Committed by GitHub
Browse files

feat(jenkins): Add Jenkins plugin manager (#6668)

parent 82c1a738
Branches
Tags
No related merge requests found
email-ext:1.2.3
apache-httpcomponents-client-4-api:4.4.10-2.0 # comment
authentication-tokens:1.2
blueocean:1.21.0 # another comment
#blueocean:1.22.0
# this line is completely ignored
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`manager/jenkins/extract extractPackageFile() extracts multiple image lines 1`] = `
Array [
Object {
"currentValue": "1.2.3",
"datasource": "jenkins-plugins",
"depName": "email-ext",
"versioning": "docker",
},
Object {
"currentValue": "4.4.10-2.0",
"datasource": "jenkins-plugins",
"depName": "apache-httpcomponents-client-4-api",
"versioning": "docker",
},
Object {
"currentValue": "1.2",
"datasource": "jenkins-plugins",
"depName": "authentication-tokens",
"versioning": "docker",
},
Object {
"currentValue": "1.21.0",
"datasource": "jenkins-plugins",
"depName": "blueocean",
"versioning": "docker",
},
]
`;
import { readFileSync } from 'fs';
import { getName } from '../../../test/util';
import { extractPackageFile } from './extract';
const pluginsFile = readFileSync(
'lib/manager/jenkins/__fixtures__/plugins.txt',
'utf8'
);
const pluginsEmptyFile = readFileSync(
'lib/manager/jenkins/__fixtures__/empty.txt',
'utf8'
);
describe(getName(__filename), () => {
describe('extractPackageFile()', () => {
it('returns empty list for an empty file', () => {
const res = extractPackageFile(pluginsEmptyFile);
expect(res.deps).toHaveLength(0);
});
it('extracts multiple image lines', () => {
const res = extractPackageFile(pluginsFile);
expect(res.deps).toMatchSnapshot();
expect(res.deps).toHaveLength(4);
});
});
});
import * as datasourceJenkins from '../../datasource/jenkins-plugins';
import { logger } from '../../logger';
import * as dockerVersioning from '../../versioning/docker';
import { PackageDependency, PackageFile } from '../common';
export function extractPackageFile(content: string): PackageFile | null {
logger.trace('jenkins.extractPackageFile()');
const deps: PackageDependency[] = [];
const regex = /^\s*(?<depName>[\d\w-]+):(?<currentValue>[^#\s]+).*$/;
for (const line of content.split('\n')) {
const match = regex.exec(line);
if (match) {
const { depName, currentValue } = match.groups;
const dep: PackageDependency = {
datasource: datasourceJenkins.id,
versioning: dockerVersioning.id,
depName,
currentValue,
};
deps.push(dep);
}
}
return { deps };
}
export { extractPackageFile } from './extract';
export const defaultConfig = {
fileMatch: ['(^|/)plugins\\.txt'],
};
The Jenkins manager suppports the following format of the plugin list:
```text
plugin1:1.2.3
plugin2:4.5 # this is a comment
# this line is ignored
```
There's no strict specification on the name of the files, but usually it's `plugins.txt`
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment