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 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
|
||||
|
||||
:Artifact:
|
||||
* **group-id** (`str`) -- Group ID of the artifact
|
||||
* **artifact-id** (`str`) -- Artifact ID of the artifact
|
||||
* **version** (`str`) -- Version of the artifact
|
||||
* **group-id** (`str`) -- Group ID of the artifact (required)
|
||||
* **artifact-id** (`str`) -- Artifact ID of the artifact (required)
|
||||
* **version** (`str`) -- Version of the artifact (required)
|
||||
* **classifier** (`str`) -- Classifier of the artifact (default '')
|
||||
* **extension** (`str`) -- Extension of the artifact
|
||||
(default 'jar')
|
||||
* **target-file-name** (`str`) -- What to name the artifact
|
||||
(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
|
||||
"""
|
||||
ar = XML.SubElement(xml_parent,
|
||||
'org.jvnet.hudson.plugins.repositoryconnector.'
|
||||
'ArtifactResolver')
|
||||
XML.SubElement(ar, 'targetDirectory').text = data['target-directory']
|
||||
artifacttop = XML.SubElement(ar, 'artifacts')
|
||||
ar = XML.SubElement(
|
||||
xml_parent,
|
||||
'org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver')
|
||||
mapping = [
|
||||
('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_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:
|
||||
rcartifact = XML.SubElement(artifacttop,
|
||||
'org.jvnet.hudson.plugins.'
|
||||
'repositoryconnector.Artifact')
|
||||
XML.SubElement(rcartifact, 'groupId').text = artifact['group-id']
|
||||
XML.SubElement(rcartifact, 'artifactId').text = artifact['artifact-id']
|
||||
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'
|
||||
rcartifact = XML.SubElement(
|
||||
artifact_top,
|
||||
'org.jvnet.hudson.plugins.repositoryconnector.Artifact')
|
||||
convert_mapping_to_xml(
|
||||
rcartifact, artifact, artifacts_mapping, fail_required=True)
|
||||
|
||||
|
||||
def doxygen(registry, xml_parent, data):
|
||||
|
@ -3,30 +3,30 @@
|
||||
<builders>
|
||||
<org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver>
|
||||
<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>
|
||||
<enableRepoLogging>true</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>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>
|
||||
</builders>
|
||||
</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