fix xpath

This commit is contained in:
Slawomir Jaranowski
2019-10-01 23:03:44 +02:00
parent cb7cfb850b
commit 33ba027849
7 changed files with 19 additions and 6 deletions

View File

@ -14,6 +14,6 @@ jobs:
with:
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
properties: '[{"prop1": "value1"}, {"prop2": "value2"}]'
sonatype-snapshots: true
sonatypeSnapshots: true
- run: cat ~/.m2/settings.xml

View File

@ -34,7 +34,7 @@ Create ```settings.xml``` with https://oss.sonatype.org/content/repositories/sna
steps:
- uses: s4u/maven-settings-action@v1
with:
sonatype-snapshots: true
sonatypeSnapshots: true
```
# License

View File

@ -8,7 +8,7 @@ inputs:
properties:
description: 'json array with properties, eg [{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
required: false
sonatype-snapshots:
sonatypeSnapshots:
description: 'add https://oss.sonatype.org/content/repositories/snapshots to repository list - true or false'
default: "false"
required: false

View File

@ -40,3 +40,15 @@ test('run with default values', () => {
expect(settingsStatus.isFile()).toBeTruthy();
expect(settingsStatus.size).toBeGreaterThan(0);
})
test('run with all feature', () => {
process.env['INPUT_SERVERES'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
process.env['INPUT_SONATYPESNAPSHOT'] = true;
console.log(cp.execSync(`node ${indexPath}`, { env: process.env }).toString());
const settingsStatus = fs.lstatSync(settingsPath);
expect(settingsStatus.isFile()).toBeTruthy();
expect(settingsStatus.size).toBeGreaterThan(0);
})

View File

@ -66,6 +66,7 @@ function fillProperties(template) {
.select(`/settings/profiles/profile[id[contains(text(),"_properties_")]]/properties`, template)[0];
JSON.parse(properties).forEach((property) => {
for (const key in property) {
const keyXml = template.createElement(key);
keyXml.textContent = property[key];
@ -75,7 +76,7 @@ function fillProperties(template) {
}
function addSonatypeSnapshots(template) {
const val = core.getInput('sonatype-snapshots');
const val = core.getInput('sonatypeSnapshots');
if (val && val.toLocaleLowerCase() == 'true') {
activateProfile(template, '_sonatype-snapshots_')
}

View File

@ -82,7 +82,7 @@ test('fillServers two servers', () => {
test('addSonatypeSnapshots activate', () => {
process.env['INPUT_SONATYPE-SNAPSHOTS'] = "true";
process.env['INPUT_SONATYPESNAPSHOTS'] = "true";
settings.addSonatypeSnapshots(xmlTestProfile);

View File

@ -1,4 +1,4 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<settings>
<interactiveMode>false</interactiveMode>