summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Carey <rcarey@dataxu.com>2014-04-02 17:08:03 -0400
committerRyan Carey <rcarey@dataxu.com>2015-09-17 13:47:05 -0400
commita39c4d85d1e0f91a5d0fe0432992d37689998478 (patch)
tree7791e2dce73e54f0cdef9876bfefa8b89ba0658d
parent59a8342f8502f82e0fdfa66068779875f8d12319 (diff)
downloadpython-jenkins-job-builder-a39c4d85d1e0f91a5d0fe0432992d37689998478.tar.gz
python-jenkins-job-builder-a39c4d85d1e0f91a5d0fe0432992d37689998478.tar.xz
python-jenkins-job-builder-a39c4d85d1e0f91a5d0fe0432992d37689998478.zip
Add support for Artifactory plugin
Artifactory support adds three modules to jenkins-job-builder: 1. Artifactory publisher 2. Artifactory wrapper (for Maven projects) 3. Generic-Artifactory wrapper (for other project types) Change-Id: I801bba707198226d63c94d869cae9167eb4906d4
-rw-r--r--jenkins_jobs/modules/helpers.py110
-rw-r--r--jenkins_jobs/modules/publishers.py142
-rw-r--r--jenkins_jobs/modules/wrappers.py271
-rw-r--r--setup.cfg4
-rw-r--r--tests/publishers/fixtures/artifactory01.xml49
-rw-r--r--tests/publishers/fixtures/artifactory01.yaml6
-rw-r--r--tests/publishers/fixtures/artifactory02.xml49
-rw-r--r--tests/publishers/fixtures/artifactory02.yaml34
-rw-r--r--tests/wrappers/fixtures/artifactory001.xml12
-rw-r--r--tests/wrappers/fixtures/artifactory001.yaml5
-rw-r--r--tests/wrappers/fixtures/artifactory002.xml24
-rw-r--r--tests/wrappers/fixtures/artifactory002.yaml19
-rw-r--r--tests/wrappers/fixtures/artifactory003.xml70
-rw-r--r--tests/wrappers/fixtures/artifactory003.yaml14
14 files changed, 809 insertions, 0 deletions
diff --git a/jenkins_jobs/modules/helpers.py b/jenkins_jobs/modules/helpers.py
index d2f3227d..e5627231 100644
--- a/jenkins_jobs/modules/helpers.py
+++ b/jenkins_jobs/modules/helpers.py
@@ -242,3 +242,113 @@ def cloudformation_stack(xml_parent, stack, xml_tag, stacks, region_dict):
XML.SubElement(step, 'cloudFormationRecipe').text = stack['recipe']
except KeyError as e:
raise MissingAttributeError(e.args[0])
+
+
+def include_exclude_patterns(xml_parent, data, yaml_prefix,
+ xml_elem_name):
+ xml_element = XML.SubElement(xml_parent, xml_elem_name)
+ XML.SubElement(xml_element, 'includePatterns').text = ','.join(
+ data.get(yaml_prefix + '-include-patterns', []))
+ XML.SubElement(xml_element, 'excludePatterns').text = ','.join(
+ data.get(yaml_prefix + '-exclude-patterns', []))
+
+
+def artifactory_deployment_patterns(xml_parent, data):
+ include_exclude_patterns(xml_parent, data, 'deployment',
+ 'artifactDeploymentPatterns')
+
+
+def artifactory_env_vars_patterns(xml_parent, data):
+ include_exclude_patterns(xml_parent, data, 'env-vars',
+ 'envVarsPatterns')
+
+
+def artifactory_optional_props(xml_parent, data, target):
+ optional_str_props = [
+ ('scopes', 'scopes'),
+ ('violationRecipients', 'violation-recipients'),
+ ('blackDuckAppName', 'black-duck-app-name'),
+ ('blackDuckAppVersion', 'black-duck-app-version'),
+ ('blackDuckReportRecipients', 'black-duck-report-recipients'),
+ ('blackDuckScopes', 'black-duck-scopes')
+ ]
+
+ for (xml_prop, yaml_prop) in optional_str_props:
+ XML.SubElement(xml_parent, xml_prop).text = data.get(
+ yaml_prop, '')
+
+ common_bool_props = [
+ # xml property name, yaml property name, default value
+ ('deployArtifacts', 'deploy-artifacts', True),
+ ('discardOldBuilds', 'discard-old-builds', False),
+ ('discardBuildArtifacts', 'discard-build-artifacts', False),
+ ('deployBuildInfo', 'publish-build-info', False),
+ ('includeEnvVars', 'env-vars-include', False),
+ ('runChecks', 'run-checks', False),
+ ('includePublishArtifacts', 'include-publish-artifacts', False),
+ ('licenseAutoDiscovery', 'license-auto-discovery', True),
+ ('enableIssueTrackerIntegration', 'enable-issue-tracker-integration',
+ False),
+ ('aggregateBuildIssues', 'aggregate-build-issues', False),
+ ('blackDuckRunChecks', 'black-duck-run-checks', False),
+ ('blackDuckIncludePublishedArtifacts',
+ 'black-duck-include-published-artifacts', False),
+ ('autoCreateMissingComponentRequests',
+ 'auto-create-missing-component-requests', True),
+ ('autoDiscardStaleComponentRequests',
+ 'auto-discard-stale-component-requests', True),
+ ('filterExcludedArtifactsFromBuild',
+ 'filter-excluded-artifacts-from-build', False)
+ ]
+
+ for (xml_prop, yaml_prop, default_value) in common_bool_props:
+ XML.SubElement(xml_parent, xml_prop).text = str(data.get(
+ yaml_prop, default_value)).lower()
+
+ if 'wrappers' in target:
+ wrapper_bool_props = [
+ ('enableResolveArtifacts', 'enable-resolve-artifacts', False),
+ ('disableLicenseAutoDiscovery',
+ 'disable-license-auto-discovery', False),
+ ('recordAllDependencies',
+ 'record-all-dependencies', False)
+ ]
+
+ for (xml_prop, yaml_prop, default_value) in wrapper_bool_props:
+ XML.SubElement(xml_parent, xml_prop).text = str(data.get(
+ yaml_prop, default_value)).lower()
+
+ if 'publishers' in target:
+ publisher_bool_props = [
+ ('evenIfUnstable', 'even-if-unstable', False),
+ ('passIdentifiedDownstream', 'pass-identified-downstream', False),
+ ('allowPromotionOfNonStagedBuilds',
+ 'allow-promotion-of-non-staged-builds', False)
+ ]
+
+ for (xml_prop, yaml_prop, default_value) in publisher_bool_props:
+ XML.SubElement(xml_parent, xml_prop).text = str(data.get(
+ yaml_prop, default_value)).lower()
+
+
+def artifactory_common_details(details, data):
+ XML.SubElement(details, 'artifactoryName').text = data.get('name', '')
+ XML.SubElement(details, 'artifactoryUrl').text = data.get('url', '')
+
+
+def artifactory_repository(xml_parent, data, target):
+ if 'release' in target:
+ XML.SubElement(xml_parent, 'keyFromText').text = data.get(
+ 'deploy-release-repo-key', '')
+ XML.SubElement(xml_parent, 'keyFromSelect').text = data.get(
+ 'deploy-release-repo-key', '')
+ XML.SubElement(xml_parent, 'dynamicMode').text = str(
+ data.get('deploy-dynamic-mode', False)).lower()
+
+ if 'snapshot' in target:
+ XML.SubElement(xml_parent, 'keyFromText').text = data.get(
+ 'deploy-snapshot-repo-key', '')
+ XML.SubElement(xml_parent, 'keyFromSelect').text = data.get(
+ 'deploy-snapshot-repo-key', '')
+ XML.SubElement(xml_parent, 'dynamicMode').text = str(
+ data.get('deploy-dynamic-mode', False)).lower()
diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index c0057f88..c4c324da 100644
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -36,6 +36,10 @@ from jenkins_jobs.modules.helpers import cloudformation_stack
from jenkins_jobs.modules.helpers import config_file_provider_settings
from jenkins_jobs.modules.helpers import findbugs_settings
from jenkins_jobs.modules.helpers import get_value_from_yaml_or_config_file
+from jenkins_jobs.modules.helpers import artifactory_deployment_patterns
+from jenkins_jobs.modules.helpers import artifactory_env_vars_patterns
+from jenkins_jobs.modules.helpers import artifactory_optional_props
+from jenkins_jobs.modules.helpers import artifactory_common_details
from jenkins_jobs.errors import (InvalidAttributeError,
JenkinsJobsException,
MissingAttributeError)
@@ -2467,6 +2471,144 @@ def maven_deploy(parser, xml_parent, data):
XML.SubElement(p, 'releaseEnvVar').text = data['release-env-var']
+def artifactory(parser, xml_parent, data):
+ """ yaml: artifactory
+ Uses/requires the Artifactory plugin to deploy artifacts to
+ Artifactory Server.
+
+ Requires the Jenkins `Artifactory Plugin.
+ :jenkins-wiki: `Artifactory Plugin <Artifactory+Plugin>`.
+
+ :arg str url: Artifactory server url (default '')
+ :arg str name: Artifactory user with permissions use for
+ connected to the selected Artifactory Server (default '')
+ :arg str release-repo-key: Release repository name (default '')
+ :arg str snapshot-repo-key: Snapshots repository name (default '')
+ :arg bool publish-build-info: Push build metadata with artifacts
+ (default False)
+ :arg bool discard-old-builds:
+ Remove older build info from Artifactory (default False)
+ :arg bool discard-build-artifacts:
+ Remove older build artifacts from Artifactory (default False)
+ :arg bool even-if-unstable: Deploy artifacts even when the build
+ is unstable (default False)
+ :arg bool run-checks: Run automatic license scanning check after the
+ build is complete (default False)
+ :arg bool include-publish-artifacts: Include the build's published
+ module artifacts in the license violation checks if they are
+ also used as dependencies for other modules in this build
+ (default False)
+ :arg bool pass-identified-downstream: When true, a build parameter
+ named ARTIFACTORY_BUILD_ROOT with a value of
+ ${JOB_NAME}-${BUILD_NUMBER} will be sent to downstream builds
+ (default False)
+ :arg bool license-auto-discovery: Tells Artifactory not to try
+ and automatically analyze and tag the build's dependencies
+ with license information upon deployment (default True)
+ :arg bool enable-issue-tracker-integration: When the Jenkins
+ JIRA plugin is enabled, synchronize information about JIRA
+ issues to Artifactory and attach issue information to build
+ artifacts (default False)
+ :arg bool aggregate-build-issues: When the Jenkins JIRA plugin
+ is enabled, include all issues from previous builds up to the
+ latest build status defined in "Aggregation Build Status"
+ (default False)
+ :arg bool allow-promotion-of-non-staged-builds: The build
+ promotion operation will be available to all successful builds
+ instead of only staged ones (default False)
+ :arg bool filter-excluded-artifacts-from-build: Add the excluded
+ files to the excludedArtifacts list and remove them from the
+ artifacts list in the build info (default False)
+ :arg str scopes: A list of dependency scopes/configurations to run
+ license violation checks on. If left empty all dependencies from
+ all scopes will be checked (default '')
+ :arg str violation-recipients: Recipients that need to be notified
+ of license violations in the build info (default '')
+ :arg list matrix-params: Semicolon-separated list of properties to
+ attach to all deployed artifacts in addition to the default ones:
+ build.name, build.number, and vcs.revision (default [])
+ :arg str black-duck-app-name: The existing Black Duck Code Center
+ application name (default '')
+ :arg str black-duck-app-version: The existing Black Duck Code Center
+ application version (default '')
+ :arg str black-duck-report-recipients: Recipients that will be emailed
+ a report after the automatic Black Duck Code Center compliance checks
+ finished (default '')
+ :arg str black-duck-scopes: A list of dependency scopes/configurations
+ to run Black Duck Code Center compliance checks on. If left empty
+ all dependencies from all scopes will be checked (default '')
+ :arg bool black-duck-run-checks: Automatic Black Duck Code Center
+ compliance checks will occur after the build completes
+ (default False)
+ :arg bool black-duck-include-published-artifacts: Include the build's
+ published module artifacts in the license violation checks if they
+ are also used as dependencies for other modules in this build
+ (default False)
+ :arg bool auto-create-missing-component-requests: Auto create
+ missing components in Black Duck Code Center application after
+ the build is completed and deployed in Artifactory
+ (default True)
+ :arg bool auto-discard-stale-component-requests: Auto discard
+ stale components in Black Duck Code Center application after
+ the build is completed and deployed in Artifactory
+ (default True)
+ :arg bool deploy-artifacts: Push artifacts to the Artifactory
+ Server. Use deployment-include-patterns and
+ deployment-exclude-patterns to filter deploy artifacts. (default True)
+ :arg list deployment-include-patterns: New line or comma separated mappings
+ of build artifacts to published artifacts. Supports Ant-style wildcards
+ mapping to target directories. E.g.: */*.zip=>dir (default [])
+ :arg list deployment-exclude-patterns: New line or comma separated patterns
+ for excluding artifacts from deployment to Artifactory (default [])
+ :arg bool env-vars-include: Include all environment variables
+ accessible by the build process. Jenkins-specific env variables
+ are always included. Use env-vars-include-patterns and
+ env-vars-exclude-patterns to filter variables to publish,
+ (default False)
+ :arg list env-vars-include-patterns: Comma or space-separated list of
+ environment variables that will be included as part of the published
+ build info. Environment variables may contain the * and the ? wildcards
+ (default [])
+ :arg list env-vars-exclude-patterns: Comma or space-separated list of
+ environment variables that will be excluded from the published
+ build info (default [])
+
+ Example:
+
+ .. literalinclude:: /../../tests/publishers/fixtures/artifactory01.yaml
+
+ .. literalinclude:: /../../tests/publishers/fixtures/artifactory02.yaml
+
+ """
+
+ artifactory = XML.SubElement(
+ xml_parent, 'org.jfrog.hudson.ArtifactoryRedeployPublisher')
+
+ # optional_props
+ artifactory_optional_props(artifactory, data, 'publishers')
+
+ XML.SubElement(artifactory, 'matrixParams').text = ','.join(
+ data.get('matrix-params', []))
+
+ # details
+ details = XML.SubElement(artifactory, 'details')
+ artifactory_common_details(details, data)
+
+ XML.SubElement(details, 'repositoryKey').text = data.get(
+ 'release-repo-key', '')
+ XML.SubElement(details, 'snapshotsRepositoryKey').text = data.get(
+ 'snapshot-repo-key', '')
+
+ plugin = XML.SubElement(details, 'stagingPlugin')
+ XML.SubElement(plugin, 'pluginName').text = 'None'
+
+ # artifactDeploymentPatterns
+ artifactory_deployment_patterns(artifactory, data)
+
+ # envVarsPatterns
+ artifactory_env_vars_patterns(artifactory, data)
+
+
def text_finder(parser, xml_parent, data):
"""yaml: text-finder
This plugin lets you search keywords in the files you specified and
diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py
index 69d551f2..35176422 100644
--- a/jenkins_jobs/modules/wrappers.py
+++ b/jenkins_jobs/modules/wrappers.py
@@ -31,6 +31,11 @@ from jenkins_jobs.errors import (JenkinsJobsException,
MissingAttributeError)
from jenkins_jobs.modules.builders import create_builders
from jenkins_jobs.modules.helpers import config_file_provider_builder
+from jenkins_jobs.modules.helpers import artifactory_common_details
+from jenkins_jobs.modules.helpers import artifactory_repository
+from jenkins_jobs.modules.helpers import artifactory_deployment_patterns
+from jenkins_jobs.modules.helpers import artifactory_env_vars_patterns
+from jenkins_jobs.modules.helpers import artifactory_optional_props
logger = logging.getLogger(__name__)
@@ -1647,6 +1652,272 @@ def android_emulator(parser, xml_parent, data):
XML.SubElement(root, 'executable').text = str(data.get('exe', ''))
+def artifactory_maven(parser, xml_parent, data):
+ """ yaml: artifactory-maven
+ Wrapper for non-Maven projects. Requires the
+ :jenkins-wiki:`Artifactory Plugin <Artifactory+Plugin>`
+
+ :arg str url: URL of the Artifactory server. e.g.
+ http://www.jfrog.com/artifactory/ (default '')
+ :arg str name: Artifactory user with permissions use for
+ connected to the selected Artifactory Server
+ (default '')
+ :arg str repo-key: Name of the repository to search for
+ artifact dependencies. Provide a single repo-key or provide
+ separate release-repo-key and snapshot-repo-key.
+ :arg str release-repo-key: Release repository name. Value of
+ repo-key take priority over release-repo-key if provided.
+ :arg str snapshot-repo-key: Snapshots repository name. Value of
+ repo-key take priority over release-repo-key if provided.
+
+ Example:
+
+ .. literalinclude:: /../../tests/wrappers/fixtures/artifactory001.yaml
+ :language: yaml
+
+ """
+
+ artifactory = XML.SubElement(
+ xml_parent,
+ 'org.jfrog.hudson.maven3.ArtifactoryMaven3NativeConfigurator')
+
+ # details
+ details = XML.SubElement(artifactory, 'details')
+ artifactory_common_details(details, data)
+
+ if 'repo-key' in data:
+ XML.SubElement(
+ details, 'downloadRepositoryKey').text = data['repo-key']
+ else:
+ XML.SubElement(
+ details, 'downloadSnapshotRepositoryKey').text = data.get(
+ 'snapshot-repo-key', '')
+ XML.SubElement(
+ details, 'downloadReleaseRepositoryKey').text = data.get(
+ 'release-repo-key', '')
+
+
+def artifactory_generic(parser, xml_parent, data):
+ """ yaml: artifactory-generic
+ Wrapper for non-Maven projects. Requires the
+ :jenkins-wiki:`Artifactory Plugin <Artifactory+Plugin>`
+
+ :arg str url: URL of the Artifactory server. e.g.
+ http://www.jfrog.com/artifactory/ (default: '')
+ :arg str name: Artifactory user with permissions use for
+ connected to the selected Artifactory Server
+ (default '')
+ :arg str repo-key: Release repository name (default '')
+ :arg str snapshot-repo-key: Snapshots repository name (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 [])
+ :arg list resolve-pattern: List of references to other
+ artifacts that this build should use as dependencies.
+ :arg list matrix-params: List of properties to attach to all deployed
+ artifacts in addition to the default ones: build.name, build.number,
+ and vcs.revision (default [])
+ :arg bool deploy-build-info: Deploy jenkins build metadata with
+ artifacts to Artifactory (default False)
+ :arg bool env-vars-include: Include environment variables accessible by
+ the build process. Jenkins-specific env variables are always included.
+ Use the env-vars-include-patterns and env-vars-exclude-patterns to
+ filter the environment variables published to artifactory.
+ (default False)
+ :arg list env-vars-include-patterns: List of environment variable patterns
+ for including env vars as part of the published build info. Environment
+ variables may contain the * and the ? wildcards (default [])
+ :arg list env-vars-exclude-patterns: List of environment variable patterns
+ that determine the env vars excluded from the published build info
+ (default [])
+ :arg bool discard-old-builds:
+ Remove older build info from Artifactory (default False)
+ :arg bool discard-build-artifacts:
+ Remove older build artifacts from Artifactory (default False)
+
+ Example:
+
+ .. literalinclude:: /../../tests/wrappers/fixtures/artifactory002.yaml
+ :language: yaml
+
+ """
+
+ artifactory = XML.SubElement(
+ xml_parent,
+ 'org.jfrog.hudson.generic.ArtifactoryGenericConfigurator')
+
+ # details
+ details = XML.SubElement(artifactory, 'details')
+ artifactory_common_details(details, data)
+
+ XML.SubElement(details, 'repositoryKey').text = data.get('repo-key', '')
+ XML.SubElement(details, 'snapshotsRepositoryKey').text = data.get(
+ 'snapshot-repo-key', '')
+
+ XML.SubElement(artifactory, 'deployPattern').text = ','.join(data.get(
+ 'deploy-pattern', []))
+ XML.SubElement(artifactory, 'resolvePattern').text = ','.join(
+ data.get('resolve-pattern', []))
+ XML.SubElement(artifactory, 'matrixParams').text = ','.join(
+ data.get('matrix-params', []))
+
+ XML.SubElement(artifactory, 'deployBuildInfo').text = str(
+ data.get('deploy-build-info', False)).lower()
+ XML.SubElement(artifactory, 'includeEnvVars').text = str(
+ data.get('env-vars-include', False)).lower()
+ XML.SubElement(artifactory, 'discardOldBuilds').text = str(
+ data.get('discard-old-builds', False)).lower()
+ XML.SubElement(artifactory, 'discardBuildArtifacts').text = str(
+ data.get('discard-build-artifacts', True)).lower()
+
+ # envVarsPatterns
+ artifactory_env_vars_patterns(artifactory, data)
+
+
+def artifactory_maven_freestyle(parser, xml_parent, data):
+ """ yaml: artifactory-maven-freestyle
+ Wrapper for Free Stype projects. Requires the Artifactory plugin.
+ Requires :jenkins-wiki:`Artifactory Plugin <Artifactory+Plugin>`
+
+ :arg str url: URL of the Artifactory server. e.g.
+ http://www.jfrog.com/artifactory/ (default: '')
+ :arg str name: Artifactory user with permissions use for
+ connected to the selected Artifactory Server (default '')
+ :arg str release-repo-key: Release repository name (default '')
+ :arg str snapshot-repo-key: Snapshots repository name (default '')
+ :arg bool publish-build-info: Push build metadata with artifacts
+ (default False)
+ :arg bool discard-old-builds:
+ Remove older build info from Artifactory (default True)
+ :arg bool discard-build-artifacts:
+ Remove older build artifacts from Artifactory (default False)
+ :arg bool include-env-vars: Include all environment variables
+ accessible by the build process. Jenkins-specific env variables
+ are always included (default False)
+ :arg bool run-checks: Run automatic license scanning check after the
+ build is complete (default False)
+ :arg bool include-publish-artifacts: Include the build's published
+ module artifacts in the license violation checks if they are
+ also used as dependencies for other modules in this build
+ (default False)
+ :arg bool license-auto-discovery: Tells Artifactory not to try
+ and automatically analyze and tag the build's dependencies
+ with license information upon deployment (default True)
+ :arg bool enable-issue-tracker-integration: When the Jenkins
+ JIRA plugin is enabled, synchronize information about JIRA
+ issues to Artifactory and attach issue information to build
+ artifacts (default False)
+ :arg bool aggregate-build-issues: When the Jenkins JIRA plugin
+ is enabled, include all issues from previous builds up to the
+ latest build status defined in "Aggregation Build Status"
+ (default False)
+ :arg bool filter-excluded-artifacts-from-build: Add the excluded
+ files to the excludedArtifacts list and remove them from the
+ artifacts list in the build info (default False)
+ :arg str scopes: A list of dependency scopes/configurations to run
+ license violation checks on. If left empty all dependencies from
+ all scopes will be checked (default '')
+ :arg str violation-recipients: Recipients that need to be notified
+ of license violations in the build info (default '')
+ :arg list matrix-params: List of properties to attach to all
+ deployed artifacts in addition to the default ones:
+ build.name, build.number, and vcs.revision (default '')
+ :arg str black-duck-app-name: The existing Black Duck Code Center
+ application name (default '')
+ :arg str black-duck-app-version: The existing Black Duck Code Center
+ application version (default '')
+ :arg str black-duck-report-recipients: Recipients that will be emailed
+ a report after the automatic Black Duck Code Center compliance checks
+ finished (default '')
+ :arg str black-duck-scopes: A list of dependency scopes/configurations
+ to run Black Duck Code Center compliance checks on. If left empty
+ all dependencies from all scopes will be checked (default '')
+ :arg bool black-duck-run-checks: Automatic Black Duck Code Center
+ compliance checks will occur after the build completes
+ (default False)
+ :arg bool black-duck-include-published-artifacts: Include the build's
+ published module artifacts in the license violation checks if they
+ are also used as dependencies for other modules in this build
+ (default False)
+ :arg bool auto-create-missing-component-requests: Auto create
+ missing components in Black Duck Code Center application after
+ the build is completed and deployed in Artifactory
+ (default True)
+ :arg bool auto-discard-stale-component-requests: Auto discard
+ stale components in Black Duck Code Center application after
+ the build is completed and deployed in Artifactory
+ (default True)
+ :arg bool deploy-artifacts: Push artifacts to the Artifactory
+ Server. The specific artifacts to push are controlled using
+ the deployment-include-patterns and deployment-exclude-patterns.
+ (default True)
+ :arg list deployment-include-patterns: List of patterns for including
+ build artifacts to publish to artifactory. (default[]')
+ :arg list deployment-exclude-patterns: List of patterns
+ for excluding artifacts from deployment to Artifactory
+ (default [])
+ :arg bool env-vars-include: Include environment variables
+ accessible by the build process. Jenkins-specific env variables
+ are always included. Environment variables can be filtered using
+ the env-vars-include-patterns nad env-vars-exclude-patterns.
+ (default False)
+ :arg list env-vars-include-patterns: List of environment variable patterns
+ that will be included as part of the published build info. Environment
+ variables may contain the * and the ? wildcards (default [])
+ :arg list env-vars-exclude-patterns: List of environment variable patterns
+ that will be excluded from the published build info
+ (default [])
+
+ Example:
+
+ .. literalinclude:: /../../tests/wrappers/fixtures/artifactory003.yaml
+ :language: yaml
+
+ """
+
+ artifactory = XML.SubElement(
+ xml_parent,
+ 'org.jfrog.hudson.maven3.ArtifactoryMaven3Configurator')
+
+ # details
+ details = XML.SubElement(artifactory, 'details')
+ artifactory_common_details(details, data)
+
+ deploy_release = XML.SubElement(details, 'deployReleaseRepository')
+ artifactory_repository(deploy_release, data, 'release')
+
+ deploy_snapshot = XML.SubElement(details, 'deploySnapshotRepository')
+ artifactory_repository(deploy_snapshot, data, 'snapshot')
+
+ XML.SubElement(details, 'stagingPlugin').text = data.get(
+ 'resolve-staging-plugin', '')
+
+ # resolverDetails
+ resolver = XML.SubElement(artifactory, 'resolverDetails')
+ artifactory_common_details(resolver, data)
+
+ resolve_snapshot = XML.SubElement(resolver, 'resolveSnapshotRepository')
+ artifactory_repository(resolve_snapshot, data, 'snapshot')
+
+ deploy_release = XML.SubElement(resolver, 'resolveReleaseRepository')
+ artifactory_repository(deploy_release, data, 'release')
+
+ XML.SubElement(resolver, 'stagingPlugin').text = data.get(
+ 'resolve-staging-plugin', '')
+
+ # artifactDeploymentPatterns
+ artifactory_deployment_patterns(artifactory, data)
+
+ # envVarsPatterns
+ artifactory_env_vars_patterns(artifactory, data)
+
+ XML.SubElement(artifactory, 'matrixParams').text = ','.join(
+ data.get('matrix-params', []))
+
+ # optional__props
+ artifactory_optional_props(artifactory, data, 'wrappers')
+
+
class Wrappers(jenkins_jobs.modules.base.Base):
sequence = 80
diff --git a/setup.cfg b/setup.cfg
index 3acef4f4..c7814eea 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -137,6 +137,7 @@ jenkins_jobs.publishers =
aggregate-tests=jenkins_jobs.modules.publishers:aggregate_tests
archive=jenkins_jobs.modules.publishers:archive
artifact-deployer=jenkins_jobs.modules.publishers:artifact_deployer
+ artifactory=jenkins_jobs.modules.publishers:artifactory
blame-upstream=jenkins_jobs.modules.publishers:blame_upstream
build-publisher=jenkins_jobs.modules.publishers:build_publisher
campfire=jenkins_jobs.modules.publishers:campfire
@@ -251,6 +252,9 @@ jenkins_jobs.triggers =
jenkins_jobs.wrappers =
android-emulator=jenkins_jobs.modules.wrappers:android_emulator
ansicolor=jenkins_jobs.modules.wrappers:ansicolor
+ artifactory-generic=jenkins_jobs.modules.wrappers:artifactory_generic
+ artifactory-maven=jenkins_jobs.modules.wrappers:artifactory_maven
+ artifactory-maven-freestyle=jenkins_jobs.modules.wrappers:artifactory_maven_freestyle
build-name=jenkins_jobs.modules.wrappers:build_name
build-user-vars=jenkins_jobs.modules.wrappers:build_user_vars
ci-skip=jenkins_jobs.modules.wrappers:ci_skip
diff --git a/tests/publishers/fixtures/artifactory01.xml b/tests/publishers/fixtures/artifactory01.xml
new file mode 100644
index 00000000..bf1691c5
--- /dev/null
+++ b/tests/publishers/fixtures/artifactory01.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <publishers>
+ <org.jfrog.hudson.ArtifactoryRedeployPublisher>
+ <scopes/>
+ <violationRecipients/>
+ <blackDuckAppName/>
+ <blackDuckAppVersion/>
+ <blackDuckReportRecipients/>
+ <blackDuckScopes/>
+ <deployArtifacts>true</deployArtifacts>
+ <discardOldBuilds>false</discardOldBuilds>
+ <discardBuildArtifacts>false</discardBuildArtifacts>
+ <deployBuildInfo>false</deployBuildInfo>
+ <includeEnvVars>false</includeEnvVars>
+ <runChecks>false</runChecks>
+ <includePublishArtifacts>false</includePublishArtifacts>
+ <licenseAutoDiscovery>true</licenseAutoDiscovery>
+ <enableIssueTrackerIntegration>false</enableIssueTrackerIntegration>
+ <aggregateBuildIssues>false</aggregateBuildIssues>
+ <blackDuckRunChecks>false</blackDuckRunChecks>
+ <blackDuckIncludePublishedArtifacts>false</blackDuckIncludePublishedArtifacts>
+ <autoCreateMissingComponentRequests>true</autoCreateMissingComponentRequests>
+ <autoDiscardStaleComponentRequests>true</autoDiscardStaleComponentRequests>
+ <filterExcludedArtifactsFromBuild>false</filterExcludedArtifactsFromBuild>
+ <evenIfUnstable>false</evenIfUnstable>
+ <passIdentifiedDownstream>false</passIdentifiedDownstream>
+ <allowPromotionOfNonStagedBuilds>false</allowPromotionOfNonStagedBuilds>
+ <matrixParams/>
+ <details>
+ <artifactoryName>test</artifactoryName>
+ <artifactoryUrl>http://artifactory.example.net/artifactory</artifactoryUrl>
+ <repositoryKey>libs-release-local</repositoryKey>
+ <snapshotsRepositoryKey>libs-snapshot-local</snapshotsRepositoryKey>
+ <stagingPlugin>
+ <pluginName>None</pluginName>
+ </stagingPlugin>
+ </details>
+ <artifactDeploymentPatterns>
+ <includePatterns/>
+ <excludePatterns/>
+ </artifactDeploymentPatterns>
+ <envVarsPatterns>
+ <includePatterns/>
+ <excludePatterns/>
+ </envVarsPatterns>
+ </org.jfrog.hudson.ArtifactoryRedeployPublisher>
+ </publishers>
+</project>
diff --git a/tests/publishers/fixtures/artifactory01.yaml b/tests/publishers/fixtures/artifactory01.yaml
new file mode 100644
index 00000000..45e77bcc
--- /dev/null
+++ b/tests/publishers/fixtures/artifactory01.yaml
@@ -0,0 +1,6 @@
+publishers:
+ - artifactory:
+ url: http://artifactory.example.net/artifactory
+ name: 'test'
+ release-repo-key: libs-release-local
+ snapshot-repo-key: libs-snapshot-local
diff --git a/tests/publishers/fixtures/artifactory02.xml b/tests/publishers/fixtures/artifactory02.xml
new file mode 100644
index 00000000..064c9ac9
--- /dev/null
+++ b/tests/publishers/fixtures/artifactory02.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <publishers>
+ <org.jfrog.hudson.ArtifactoryRedeployPublisher>
+ <scopes/>
+ <violationRecipients>myfake@email.com</violationRecipients>
+ <blackDuckAppName>myapp</blackDuckAppName>
+ <blackDuckAppVersion>1.0</blackDuckAppVersion>
+ <blackDuckReportRecipients>myfake@email.com</blackDuckReportRecipients>
+ <blackDuckScopes/>
+ <deployArtifacts>true</deployArtifacts>
+ <discardOldBuilds>true</discardOldBuilds>
+ <discardBuildArtifacts>true</discardBuildArtifacts>
+ <deployBuildInfo>true</deployBuildInfo>
+ <includeEnvVars>true</includeEnvVars>
+ <runChecks>true</runChecks>
+ <includePublishArtifacts>true</includePublishArtifacts>
+ <licenseAutoDiscovery>true</licenseAutoDiscovery>
+ <enableIssueTrackerIntegration>false</enableIssueTrackerIntegration>
+ <aggregateBuildIssues>true</aggregateBuildIssues>
+ <blackDuckRunChecks>true</blackDuckRunChecks>
+ <blackDuckIncludePublishedArtifacts>true</blackDuckIncludePublishedArtifacts>
+ <autoCreateMissingComponentRequests>false</autoCreateMissingComponentRequests>
+ <autoDiscardStaleComponentRequests>false</autoDiscardStaleComponentRequests>
+ <filterExcludedArtifactsFromBuild>true</filterExcludedArtifactsFromBuild>
+ <evenIfUnstable>true</evenIfUnstable>
+ <passIdentifiedDownstream>true</passIdentifiedDownstream>
+ <allowPromotionOfNonStagedBuilds>true</allowPromotionOfNonStagedBuilds>
+ <matrixParams/>
+ <details>
+ <artifactoryName>test</artifactoryName>
+ <artifactoryUrl>http://artifactory.example.net/artifactory</artifactoryUrl>
+ <repositoryKey>libs-release-local</repositoryKey>
+ <snapshotsRepositoryKey>libs-snapshot-local</snapshotsRepositoryKey>
+ <stagingPlugin>
+ <pluginName>None</pluginName>
+ </stagingPlugin>
+ </details>
+ <artifactDeploymentPatterns>
+ <includePatterns/>
+ <excludePatterns/>
+ </artifactDeploymentPatterns>
+ <envVarsPatterns>
+ <includePatterns/>
+ <excludePatterns/>
+ </envVarsPatterns>
+ </org.jfrog.hudson.ArtifactoryRedeployPublisher>
+ </publishers>
+</project>
diff --git a/tests/publishers/fixtures/artifactory02.yaml b/tests/publishers/fixtures/artifactory02.yaml
new file mode 100644
index 00000000..527cc77e
--- /dev/null
+++ b/tests/publishers/fixtures/artifactory02.yaml
@@ -0,0 +1,34 @@
+publishers:
+ - artifactory:
+ url: http://artifactory.example.net/artifactory
+ name: 'test'
+ release-repo-key: libs-release-local
+ snapshot-repo-key: libs-snapshot-local
+ publish-build-info: true
+ discard-old-builds: true
+ discard-build-artifacts: true
+ even-if-unstable: true
+ run-checks: true
+ include-publish-artifacts: true
+ pass-identified-downstream: true
+ license-auto-discovery: true
+ aggregate-build-issues: true
+ allow-promotion-of-non-staged-builds: true
+ filter-excluded-artifacts-from-build: true
+ violation-recipients: myfake@email.com
+ matrix-params: []
+ black-duck-app-name: myapp
+ black-duck-app-version: '1.0'
+ black-duck-report-recipients: myfake@email.com
+ black-duck-scopes: []
+ black-duck-run-checks: true
+ black-duck-include-published-artifacts: true
+ auto-create-missing-component-requests: false
+ auto-discard-stale-component-requests: false
+ deploy-artifacts: true
+ deployment-include-patterns: []
+ deployment-exclude-patterns: []
+ env-vars-include: true
+ env-vars-include-patterns: []
+ env-vars-exclude-patterns: []
+
diff --git a/tests/wrappers/fixtures/artifactory001.xml b/tests/wrappers/fixtures/artifactory001.xml
new file mode 100644
index 00000000..c1e570e4
--- /dev/null
+++ b/tests/wrappers/fixtures/artifactory001.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <buildWrappers>
+ <org.jfrog.hudson.maven3.ArtifactoryMaven3NativeConfigurator>
+ <details>
+ <artifactoryName>test</artifactoryName>
+ <artifactoryUrl>http://artifactory.example.net/artifactory</artifactoryUrl>
+ <downloadRepositoryKey>repo</downloadRepositoryKey>
+ </details>
+ </org.jfrog.hudson.maven3.ArtifactoryMaven3NativeConfigurator>
+ </buildWrappers>
+</project>
diff --git a/tests/wrappers/fixtures/artifactory001.yaml b/tests/wrappers/fixtures/artifactory001.yaml
new file mode 100644
index 00000000..4803cb28
--- /dev/null
+++ b/tests/wrappers/fixtures/artifactory001.yaml
@@ -0,0 +1,5 @@
+wrappers:
+ - artifactory-maven:
+ url: http://artifactory.example.net/artifactory
+ name: 'test'
+ repo-key: repo
diff --git a/tests/wrappers/fixtures/artifactory002.xml b/tests/wrappers/fixtures/artifactory002.xml
new file mode 100644
index 00000000..15ce1303
--- /dev/null
+++ b/tests/wrappers/fixtures/artifactory002.xml
@@ -0,0 +1,24 @@
+<?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>
+ <repositoryKey>release-repo</repositoryKey>
+ <snapshotsRepositoryKey>snapshot-repo</snapshotsRepositoryKey>
+ </details>
+ <deployPattern>*.zip=&gt;results</deployPattern>
+ <resolvePattern>libs-release-local:prod/*=&gt;prod-jars</resolvePattern>
+ <matrixParams>custom_prop=${PROJECT_ENV_VAR}</matrixParams>
+ <deployBuildInfo>true</deployBuildInfo>
+ <includeEnvVars>true</includeEnvVars>
+ <discardOldBuilds>true</discardOldBuilds>
+ <discardBuildArtifacts>true</discardBuildArtifacts>
+ <envVarsPatterns>
+ <includePatterns>PROJECT_*,ORG_*</includePatterns>
+ <excludePatterns/>
+ </envVarsPatterns>
+ </org.jfrog.hudson.generic.ArtifactoryGenericConfigurator>
+ </buildWrappers>
+</project>
diff --git a/tests/wrappers/fixtures/artifactory002.yaml b/tests/wrappers/fixtures/artifactory002.yaml
new file mode 100644
index 00000000..4604b15a
--- /dev/null
+++ b/tests/wrappers/fixtures/artifactory002.yaml
@@ -0,0 +1,19 @@
+wrappers:
+ - artifactory-generic:
+ url: http://artifactory.example.net/artifactory
+ name: 'test'
+ deploy-build-info: true
+ repo-key: 'release-repo'
+ snapshot-repo-key: 'snapshot-repo'
+ deploy-pattern:
+ - '*.zip=>results'
+ resolve-pattern:
+ - 'libs-release-local:prod/*=>prod-jars'
+ matrix-params:
+ - 'custom_prop=${PROJECT_ENV_VAR}'
+ env-vars-include: true
+ env-vars-include-patterns:
+ - 'PROJECT_*'
+ - 'ORG_*'
+ discard-old-builds: true
+ discard-build-artifacts: true
diff --git a/tests/wrappers/fixtures/artifactory003.xml b/tests/wrappers/fixtures/artifactory003.xml
new file mode 100644
index 00000000..def8794a
--- /dev/null
+++ b/tests/wrappers/fixtures/artifactory003.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <buildWrappers>
+ <org.jfrog.hudson.maven3.ArtifactoryMaven3Configurator>
+ <details>
+ <artifactoryName>test</artifactoryName>
+ <artifactoryUrl>http://artifactory.example.net/artifactory</artifactoryUrl>
+ <deployReleaseRepository>
+ <keyFromText/>
+ <keyFromSelect/>
+ <dynamicMode>false</dynamicMode>
+ </deployReleaseRepository>
+ <deploySnapshotRepository>
+ <keyFromText/>
+ <keyFromSelect/>
+ <dynamicMode>false</dynamicMode>
+ </deploySnapshotRepository>
+ <stagingPlugin/>
+ </details>
+ <resolverDetails>
+ <artifactoryName>test</artifactoryName>
+ <artifactoryUrl>http://artifactory.example.net/artifactory</artifactoryUrl>
+ <resolveSnapshotRepository>
+ <keyFromText/>
+ <keyFromSelect/>
+ <dynamicMode>false</dynamicMode>
+ </resolveSnapshotRepository>
+ <resolveReleaseRepository>
+ <keyFromText/>
+ <keyFromSelect/>
+ <dynamicMode>false</dynamicMode>
+ </resolveReleaseRepository>
+ <stagingPlugin/>
+ </resolverDetails>
+ <artifactDeploymentPatterns>
+ <includePatterns>*.zip=&gt;results</includePatterns>
+ <excludePatterns/>
+ </artifactDeploymentPatterns>
+ <envVarsPatterns>
+ <includePatterns>PROJECT_*,ORG_*</includePatterns>
+ <excludePatterns/>
+ </envVarsPatterns>
+ <matrixParams>custom_prop=${PROJECT_ENV_VAR}</matrixParams>
+ <scopes/>
+ <violationRecipients/>
+ <blackDuckAppName/>
+ <blackDuckAppVersion/>
+ <blackDuckReportRecipients/>
+ <blackDuckScopes/>
+ <deployArtifacts>true</deployArtifacts>
+ <discardOldBuilds>false</discardOldBuilds>
+ <discardBuildArtifacts>false</discardBuildArtifacts>
+ <deployBuildInfo>false</deployBuildInfo>
+ <includeEnvVars>true</includeEnvVars>
+ <runChecks>false</runChecks>
+ <includePublishArtifacts>false</includePublishArtifacts>
+ <licenseAutoDiscovery>true</licenseAutoDiscovery>
+ <enableIssueTrackerIntegration>false</enableIssueTrackerIntegration>
+ <aggregateBuildIssues>false</aggregateBuildIssues>
+ <blackDuckRunChecks>false</blackDuckRunChecks>
+ <blackDuckIncludePublishedArtifacts>false</blackDuckIncludePublishedArtifacts>
+ <autoCreateMissingComponentRequests>true</autoCreateMissingComponentRequests>
+ <autoDiscardStaleComponentRequests>true</autoDiscardStaleComponentRequests>
+ <filterExcludedArtifactsFromBuild>false</filterExcludedArtifactsFromBuild>
+ <enableResolveArtifacts>false</enableResolveArtifacts>
+ <disableLicenseAutoDiscovery>false</disableLicenseAutoDiscovery>
+ <recordAllDependencies>false</recordAllDependencies>
+ </org.jfrog.hudson.maven3.ArtifactoryMaven3Configurator>
+ </buildWrappers>
+</project>
diff --git a/tests/wrappers/fixtures/artifactory003.yaml b/tests/wrappers/fixtures/artifactory003.yaml
new file mode 100644
index 00000000..af9f7a84
--- /dev/null
+++ b/tests/wrappers/fixtures/artifactory003.yaml
@@ -0,0 +1,14 @@
+wrappers:
+ - artifactory-maven-freestyle:
+ url: http://artifactory.example.net/artifactory
+ name: 'test'
+ repo-key: repo
+ matrix-params:
+ - 'custom_prop=${PROJECT_ENV_VAR}'
+ deployment-include-patterns:
+ - '*.zip=>results'
+ env-vars-include: true
+ env-vars-include-patterns:
+ - 'PROJECT_*'
+ - 'ORG_*'
+