Update artifact_resolver to make use of convert_mapping_to_xml()
Update tests for minimal and full types and update docs with default and required options. Change-Id: If9aaa35e2d7943b6a49f976db83d9f6cae82005b Co-Authored-By: Thanh Ha <thanh.ha@linuxfoundation.org> Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
parent
f97acb632a
commit
3caff2f7ca
@ -973,51 +973,61 @@ def artifact_resolver(registry, xml_parent, data):
|
|||||||
|
|
||||||
:arg bool fail-on-error: Whether to fail the build on error (default false)
|
:arg bool fail-on-error: Whether to fail the build on error (default false)
|
||||||
:arg bool repository-logging: Enable repository logging (default false)
|
:arg bool repository-logging: Enable repository logging (default false)
|
||||||
:arg str target-directory: Where to resolve artifacts to
|
:arg str target-directory: Where to resolve artifacts to (required)
|
||||||
:arg list artifacts: list of artifacts to resolve
|
:arg list artifacts: list of artifacts to resolve
|
||||||
|
|
||||||
:Artifact:
|
:Artifact:
|
||||||
* **group-id** (`str`) -- Group ID of the artifact
|
* **group-id** (`str`) -- Group ID of the artifact (required)
|
||||||
* **artifact-id** (`str`) -- Artifact ID of the artifact
|
* **artifact-id** (`str`) -- Artifact ID of the artifact (required)
|
||||||
* **version** (`str`) -- Version of the artifact
|
* **version** (`str`) -- Version of the artifact (required)
|
||||||
* **classifier** (`str`) -- Classifier of the artifact (default '')
|
* **classifier** (`str`) -- Classifier of the artifact (default '')
|
||||||
* **extension** (`str`) -- Extension of the artifact
|
* **extension** (`str`) -- Extension of the artifact
|
||||||
(default 'jar')
|
(default 'jar')
|
||||||
* **target-file-name** (`str`) -- What to name the artifact
|
* **target-file-name** (`str`) -- What to name the artifact
|
||||||
(default '')
|
(default '')
|
||||||
|
|
||||||
Example:
|
Minimal Example:
|
||||||
|
|
||||||
.. literalinclude:: ../../tests/builders/fixtures/artifact-resolver.yaml
|
.. literalinclude::
|
||||||
|
../../tests/builders/fixtures/artifact-resolver-minimal.yaml
|
||||||
|
:language: yaml
|
||||||
|
|
||||||
|
Full Example:
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
../../tests/builders/fixtures/artifact-resolver-full.yaml
|
||||||
:language: yaml
|
:language: yaml
|
||||||
"""
|
"""
|
||||||
ar = XML.SubElement(xml_parent,
|
ar = XML.SubElement(
|
||||||
'org.jvnet.hudson.plugins.repositoryconnector.'
|
xml_parent,
|
||||||
'ArtifactResolver')
|
'org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver')
|
||||||
XML.SubElement(ar, 'targetDirectory').text = data['target-directory']
|
mapping = [
|
||||||
artifacttop = XML.SubElement(ar, 'artifacts')
|
('target-directory', 'targetDirectory', None),
|
||||||
|
('fail-on-error', 'failOnError', False),
|
||||||
|
('repository-logging', 'enableRepoLogging', False),
|
||||||
|
('', 'snapshotUpdatePolicy', 'never'),
|
||||||
|
('', 'releaseUpdatePolicy', 'never'),
|
||||||
|
('', 'snapshotChecksumPolicy', 'warn'),
|
||||||
|
('', 'releaseChecksumPolicy', 'warn'),
|
||||||
|
]
|
||||||
|
convert_mapping_to_xml(ar, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
artifact_top = XML.SubElement(ar, 'artifacts')
|
||||||
artifacts = data['artifacts']
|
artifacts = data['artifacts']
|
||||||
|
artifacts_mapping = [
|
||||||
|
('group-id', 'groupId', None),
|
||||||
|
('artifact-id', 'artifactId', None),
|
||||||
|
('version', 'version', None),
|
||||||
|
('classifier', 'classifier', ''),
|
||||||
|
('extension', 'extension', 'jar'),
|
||||||
|
('target-file-name', 'targetFileName', ''),
|
||||||
|
]
|
||||||
for artifact in artifacts:
|
for artifact in artifacts:
|
||||||
rcartifact = XML.SubElement(artifacttop,
|
rcartifact = XML.SubElement(
|
||||||
'org.jvnet.hudson.plugins.'
|
artifact_top,
|
||||||
'repositoryconnector.Artifact')
|
'org.jvnet.hudson.plugins.repositoryconnector.Artifact')
|
||||||
XML.SubElement(rcartifact, 'groupId').text = artifact['group-id']
|
convert_mapping_to_xml(
|
||||||
XML.SubElement(rcartifact, 'artifactId').text = artifact['artifact-id']
|
rcartifact, artifact, artifacts_mapping, fail_required=True)
|
||||||
XML.SubElement(rcartifact, 'classifier').text = artifact.get(
|
|
||||||
'classifier', '')
|
|
||||||
XML.SubElement(rcartifact, 'version').text = artifact['version']
|
|
||||||
XML.SubElement(rcartifact, 'extension').text = artifact.get(
|
|
||||||
'extension', 'jar')
|
|
||||||
XML.SubElement(rcartifact, 'targetFileName').text = artifact.get(
|
|
||||||
'target-file-name', '')
|
|
||||||
XML.SubElement(ar, 'failOnError').text = str(data.get(
|
|
||||||
'fail-on-error', False)).lower()
|
|
||||||
XML.SubElement(ar, 'enableRepoLogging').text = str(data.get(
|
|
||||||
'repository-logging', False)).lower()
|
|
||||||
XML.SubElement(ar, 'snapshotUpdatePolicy').text = 'never'
|
|
||||||
XML.SubElement(ar, 'releaseUpdatePolicy').text = 'never'
|
|
||||||
XML.SubElement(ar, 'snapshotChecksumPolicy').text = 'warn'
|
|
||||||
XML.SubElement(ar, 'releaseChecksumPolicy').text = 'warn'
|
|
||||||
|
|
||||||
|
|
||||||
def doxygen(registry, xml_parent, data):
|
def doxygen(registry, xml_parent, data):
|
||||||
|
@ -3,30 +3,30 @@
|
|||||||
<builders>
|
<builders>
|
||||||
<org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver>
|
<org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver>
|
||||||
<targetDirectory>foo</targetDirectory>
|
<targetDirectory>foo</targetDirectory>
|
||||||
<artifacts>
|
|
||||||
<org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
<classifier>src</classifier>
|
|
||||||
<version>1.1</version>
|
|
||||||
<extension>jar</extension>
|
|
||||||
<targetFileName>comm-log.jar</targetFileName>
|
|
||||||
</org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
|
||||||
<org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
|
||||||
<groupId>commons-lang</groupId>
|
|
||||||
<artifactId>commons-lang</artifactId>
|
|
||||||
<classifier/>
|
|
||||||
<version>1.2</version>
|
|
||||||
<extension>jar</extension>
|
|
||||||
<targetFileName/>
|
|
||||||
</org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
|
||||||
</artifacts>
|
|
||||||
<failOnError>true</failOnError>
|
<failOnError>true</failOnError>
|
||||||
<enableRepoLogging>true</enableRepoLogging>
|
<enableRepoLogging>true</enableRepoLogging>
|
||||||
<snapshotUpdatePolicy>never</snapshotUpdatePolicy>
|
<snapshotUpdatePolicy>never</snapshotUpdatePolicy>
|
||||||
<releaseUpdatePolicy>never</releaseUpdatePolicy>
|
<releaseUpdatePolicy>never</releaseUpdatePolicy>
|
||||||
<snapshotChecksumPolicy>warn</snapshotChecksumPolicy>
|
<snapshotChecksumPolicy>warn</snapshotChecksumPolicy>
|
||||||
<releaseChecksumPolicy>warn</releaseChecksumPolicy>
|
<releaseChecksumPolicy>warn</releaseChecksumPolicy>
|
||||||
|
<artifacts>
|
||||||
|
<org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
<classifier>src</classifier>
|
||||||
|
<extension>jar</extension>
|
||||||
|
<targetFileName>comm-log.jar</targetFileName>
|
||||||
|
</org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
||||||
|
<org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
<classifier/>
|
||||||
|
<extension>jar</extension>
|
||||||
|
<targetFileName/>
|
||||||
|
</org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
||||||
|
</artifacts>
|
||||||
</org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver>
|
</org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver>
|
||||||
</builders>
|
</builders>
|
||||||
</project>
|
</project>
|
24
tests/builders/fixtures/artifact-resolver-minimal.xml
Normal file
24
tests/builders/fixtures/artifact-resolver-minimal.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<builders>
|
||||||
|
<org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver>
|
||||||
|
<targetDirectory>foo</targetDirectory>
|
||||||
|
<failOnError>false</failOnError>
|
||||||
|
<enableRepoLogging>false</enableRepoLogging>
|
||||||
|
<snapshotUpdatePolicy>never</snapshotUpdatePolicy>
|
||||||
|
<releaseUpdatePolicy>never</releaseUpdatePolicy>
|
||||||
|
<snapshotChecksumPolicy>warn</snapshotChecksumPolicy>
|
||||||
|
<releaseChecksumPolicy>warn</releaseChecksumPolicy>
|
||||||
|
<artifacts>
|
||||||
|
<org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
<classifier/>
|
||||||
|
<extension>jar</extension>
|
||||||
|
<targetFileName/>
|
||||||
|
</org.jvnet.hudson.plugins.repositoryconnector.Artifact>
|
||||||
|
</artifacts>
|
||||||
|
</org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver>
|
||||||
|
</builders>
|
||||||
|
</project>
|
7
tests/builders/fixtures/artifact-resolver-minimal.yaml
Normal file
7
tests/builders/fixtures/artifact-resolver-minimal.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
builders:
|
||||||
|
- artifact-resolver:
|
||||||
|
target-directory: foo
|
||||||
|
artifacts:
|
||||||
|
- group-id: commons-logging
|
||||||
|
artifact-id: commons-logging
|
||||||
|
version: "1.1"
|
Loading…
Reference in New Issue
Block a user