Add path argument so we can customize where settings.xml will be stored

This commit is contained in:
Piotr Kruk
2022-02-03 13:44:29 +01:00
committed by Slawomir Jaranowski
parent 99450b69de
commit 654e1efa2a
4 changed files with 27 additions and 1 deletions

View File

@ -43,6 +43,9 @@ steps:
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
```
Also you can use `path` argument if your settings.xml is stored in different location.
All `server` attributes may be specified:
* `id` _(required)_
* `username`

View File

@ -6,6 +6,9 @@ branding:
color: 'green'
inputs:
path:
description: 'override default path to settings.xml which is $HOME/.m2/settings.xml'
required: false
servers:
description: 'servers definition in json array, eg: [{"id": "serverId", "username": "username", "password": "password"}]'
required: false

View File

@ -30,7 +30,12 @@ const DOMParser = require('@xmldom/xmldom').DOMParser;
const XMLSerializer = require('@xmldom/xmldom').XMLSerializer;
function getSettingsPath() {
const _path = core.getInput('path');
if (!_path) {
return path.join(os.homedir(), '.m2', 'settings.xml');
} else {
return _path;
}
}
function getTemplate(templateName) {

View File

@ -689,3 +689,18 @@ test('genereate - override', () => {
])
);
})
test('generate - custom path', () => {
if (!fs.existsSync(testHomePath)) {
fs.mkdirSync(testHomePath);
}
const mySettings = path.join(testHomePath, 'settings_custom.xml');
process.env['INPUT_PATH'] = mySettings;
settings.generate();
const settingsStatus = fs.lstatSync(mySettings);
expect(settingsStatus.isFile()).toBeTruthy();
expect(settingsStatus.size).toBeGreaterThan(0);
});