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
changes/77/651477/4
Andrey Kostrov 4 years ago
parent 1e24fceea1
commit 2bff652b03
  1. 31
      jenkins_jobs/modules/wrappers.py
  2. 1
      tests/wrappers/fixtures/artifactory002.xml
  3. 1
      tests/wrappers/fixtures/artifactory004.xml
  4. 34
      tests/wrappers/fixtures/artifactory005.xml
  5. 7
      tests/wrappers/fixtures/artifactory005.yaml
  6. 34
      tests/wrappers/fixtures/artifactory006.xml
  7. 7
      tests/wrappers/fixtures/artifactory006.yaml

@ -2437,6 +2437,14 @@ def artifactory_generic(registry, xml_parent, data):
(default '')
:arg str key-from-text: Repository key to use that can be configured
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
build artifacts to published artifacts. Supports Ant-style wildcards
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(
xml_parent,
'org.jfrog.hudson.generic.ArtifactoryGenericConfigurator')
@ -2502,6 +2511,28 @@ def artifactory_generic(registry, xml_parent, data):
helpers.convert_mapping_to_xml(
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(
'deploy-pattern', []))
XML.SubElement(artifactory, 'resolvePattern').text = ','.join(

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

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

@ -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>

@ -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" } ] }'

@ -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>

@ -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"
Loading…
Cancel
Save