Add `Specs support` for `artifactory_generic`

Add support of Artifactory Specs
https://www.jfrog.com/confluence/display/RTF/Using+File+Specs

As for now, JJB doesnt support of Artifactory Specs,
only deprecated way is supported.

This patch adds possibility for using of Specs inside Jenkins
plugin
https://www.jfrog.com/confluence/display/RTF/Jenkins+Artifactory+Plug-in
Change-Id: I69e64202972f9f9b9147fdd65daffc2734a7d0cd
This commit is contained in:
Andrey Kostrov 2019-04-10 12:04:45 +03:00
parent 1e24fceea1
commit 2bff652b03
7 changed files with 115 additions and 0 deletions

View File

@ -2437,6 +2437,14 @@ def artifactory_generic(registry, xml_parent, data):
(default '') (default '')
:arg str key-from-text: Repository key to use that can be configured :arg str key-from-text: Repository key to use that can be configured
dynamically using Jenkins variables (plugin >= 2.3.0) (default '') dynamically using Jenkins variables (plugin >= 2.3.0) (default '')
:arg str upload-spec: File Spec schema for uploading files is as follows
(default '')
:arg str download-spec: File Spec schema for downloading
files is as follows (default '')
:arg str upload-spec-file: File location for uploading Spec schema
(default '')
:arg str download-spec-file: File location for downloading Spec schema
(default '')
:arg list deploy-pattern: List of patterns for mappings :arg list deploy-pattern: List of patterns for mappings
build artifacts to published artifacts. Supports Ant-style wildcards build artifacts to published artifacts. Supports Ant-style wildcards
mapping to target directories. E.g.: */*.zip=>dir (default []) mapping to target directories. E.g.: */*.zip=>dir (default [])
@ -2470,6 +2478,7 @@ def artifactory_generic(registry, xml_parent, data):
""" """
use_specs = False
artifactory = XML.SubElement( artifactory = XML.SubElement(
xml_parent, xml_parent,
'org.jfrog.hudson.generic.ArtifactoryGenericConfigurator') 'org.jfrog.hudson.generic.ArtifactoryGenericConfigurator')
@ -2502,6 +2511,28 @@ def artifactory_generic(registry, xml_parent, data):
helpers.convert_mapping_to_xml( helpers.convert_mapping_to_xml(
details, data, mapping, fail_required=False) details, data, mapping, fail_required=False)
if 'upload-spec' in data or 'download-spec' in data:
upload_spec = data.get('upload-spec', '')
upl_spec_xml = XML.SubElement(artifactory, 'uploadSpec')
XML.SubElement(upl_spec_xml, 'spec').text = upload_spec
download_spec = data.get('download-spec', '')
dnl_spec_xml = XML.SubElement(artifactory, 'downloadSpec')
XML.SubElement(dnl_spec_xml, 'spec').text = download_spec
use_specs = True
if 'upload-spec-file' in data or 'download-spec-file' in data:
upload_spec_file = data.get('upload-spec-file', '')
upl_spec_xml = XML.SubElement(artifactory, 'uploadSpec')
XML.SubElement(upl_spec_xml, 'filePath').text = upload_spec_file
download_spec_file = data.get('download-spec-file', '')
dnl_spec_xml = XML.SubElement(artifactory, 'downloadSpec')
XML.SubElement(dnl_spec_xml, 'filePath').text = download_spec_file
use_specs = True
XML.SubElement(artifactory, 'useSpecs').text = str(use_specs).lower()
XML.SubElement(artifactory, 'deployPattern').text = ','.join(data.get( XML.SubElement(artifactory, 'deployPattern').text = ','.join(data.get(
'deploy-pattern', [])) 'deploy-pattern', []))
XML.SubElement(artifactory, 'resolvePattern').text = ','.join( XML.SubElement(artifactory, 'resolvePattern').text = ','.join(

View File

@ -8,6 +8,7 @@
<repositoryKey>release-repo</repositoryKey> <repositoryKey>release-repo</repositoryKey>
<snapshotsRepositoryKey>snapshot-repo</snapshotsRepositoryKey> <snapshotsRepositoryKey>snapshot-repo</snapshotsRepositoryKey>
</details> </details>
<useSpecs>false</useSpecs>
<deployPattern>*.zip=&gt;results</deployPattern> <deployPattern>*.zip=&gt;results</deployPattern>
<resolvePattern>libs-release-local:prod/*=&gt;prod-jars</resolvePattern> <resolvePattern>libs-release-local:prod/*=&gt;prod-jars</resolvePattern>
<matrixParams>custom_prop=${PROJECT_ENV_VAR}</matrixParams> <matrixParams>custom_prop=${PROJECT_ENV_VAR}</matrixParams>

View File

@ -11,6 +11,7 @@
<dynamicMode/> <dynamicMode/>
</deployReleaseRepository> </deployReleaseRepository>
</details> </details>
<useSpecs>false</useSpecs>
<deployPattern>*.zip=&gt;results</deployPattern> <deployPattern>*.zip=&gt;results</deployPattern>
<resolvePattern>libs-release-local:prod/*=&gt;prod-jars</resolvePattern> <resolvePattern>libs-release-local:prod/*=&gt;prod-jars</resolvePattern>
<matrixParams>custom_prop=${PROJECT_ENV_VAR}</matrixParams> <matrixParams>custom_prop=${PROJECT_ENV_VAR}</matrixParams>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jfrog.hudson.generic.ArtifactoryGenericConfigurator>
<details>
<artifactoryName>test</artifactoryName>
<artifactoryUrl>http://artifactory.example.net/artifactory</artifactoryUrl>
<deployReleaseRepository>
<keyFromText/>
<keyFromSelect/>
<dynamicMode/>
</deployReleaseRepository>
</details>
<uploadSpec>
<spec>{ &quot;files&quot;: [ { &quot;pattern&quot;: &quot;*.jar&quot;, &quot;target&quot;: &quot;release&quot; } ] }</spec>
</uploadSpec>
<downloadSpec>
<spec>{ &quot;files&quot;: [ { &quot;pattern&quot;: &quot;*.jar&quot;, &quot;target&quot;: &quot;release&quot; } ] }</spec>
</downloadSpec>
<useSpecs>true</useSpecs>
<deployPattern/>
<resolvePattern/>
<matrixParams/>
<deployBuildInfo>true</deployBuildInfo>
<includeEnvVars>false</includeEnvVars>
<discardOldBuilds>false</discardOldBuilds>
<discardBuildArtifacts>true</discardBuildArtifacts>
<envVarsPatterns>
<includePatterns/>
<excludePatterns/>
</envVarsPatterns>
</org.jfrog.hudson.generic.ArtifactoryGenericConfigurator>
</buildWrappers>
</project>

View File

@ -0,0 +1,7 @@
wrappers:
- artifactory-generic:
url: http://artifactory.example.net/artifactory
name: 'test'
deploy-build-info: true
upload-spec: '{ "files": [ { "pattern": "*.jar", "target": "release" } ] }'
download-spec: '{ "files": [ { "pattern": "*.jar", "target": "release" } ] }'

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jfrog.hudson.generic.ArtifactoryGenericConfigurator>
<details>
<artifactoryName>test</artifactoryName>
<artifactoryUrl>http://artifactory.example.net/artifactory</artifactoryUrl>
<deployReleaseRepository>
<keyFromText/>
<keyFromSelect/>
<dynamicMode/>
</deployReleaseRepository>
</details>
<uploadSpec>
<filePath>path/to/upload-file</filePath>
</uploadSpec>
<downloadSpec>
<filePath>path/to/download-file</filePath>
</downloadSpec>
<useSpecs>true</useSpecs>
<deployPattern/>
<resolvePattern/>
<matrixParams/>
<deployBuildInfo>true</deployBuildInfo>
<includeEnvVars>false</includeEnvVars>
<discardOldBuilds>false</discardOldBuilds>
<discardBuildArtifacts>true</discardBuildArtifacts>
<envVarsPatterns>
<includePatterns/>
<excludePatterns/>
</envVarsPatterns>
</org.jfrog.hudson.generic.ArtifactoryGenericConfigurator>
</buildWrappers>
</project>

View File

@ -0,0 +1,7 @@
wrappers:
- artifactory-generic:
url: http://artifactory.example.net/artifactory
name: 'test'
deploy-build-info: true
upload-spec-file: "path/to/upload-file"
download-spec-file: "path/to/download-file"