From a39c4d85d1e0f91a5d0fe0432992d37689998478 Mon Sep 17 00:00:00 2001 From: Ryan Carey Date: Wed, 2 Apr 2014 17:08:03 -0400 Subject: [PATCH] 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 --- jenkins_jobs/modules/helpers.py | 110 ++++++++ jenkins_jobs/modules/publishers.py | 142 ++++++++++ jenkins_jobs/modules/wrappers.py | 271 +++++++++++++++++++ setup.cfg | 4 + tests/publishers/fixtures/artifactory01.xml | 49 ++++ tests/publishers/fixtures/artifactory01.yaml | 6 + tests/publishers/fixtures/artifactory02.xml | 49 ++++ tests/publishers/fixtures/artifactory02.yaml | 34 +++ tests/wrappers/fixtures/artifactory001.xml | 12 + tests/wrappers/fixtures/artifactory001.yaml | 5 + tests/wrappers/fixtures/artifactory002.xml | 24 ++ tests/wrappers/fixtures/artifactory002.yaml | 19 ++ tests/wrappers/fixtures/artifactory003.xml | 70 +++++ tests/wrappers/fixtures/artifactory003.yaml | 14 + 14 files changed, 809 insertions(+) create mode 100644 tests/publishers/fixtures/artifactory01.xml create mode 100644 tests/publishers/fixtures/artifactory01.yaml create mode 100644 tests/publishers/fixtures/artifactory02.xml create mode 100644 tests/publishers/fixtures/artifactory02.yaml create mode 100644 tests/wrappers/fixtures/artifactory001.xml create mode 100644 tests/wrappers/fixtures/artifactory001.yaml create mode 100644 tests/wrappers/fixtures/artifactory002.xml create mode 100644 tests/wrappers/fixtures/artifactory002.yaml create mode 100644 tests/wrappers/fixtures/artifactory003.xml create mode 100644 tests/wrappers/fixtures/artifactory003.yaml diff --git a/jenkins_jobs/modules/helpers.py b/jenkins_jobs/modules/helpers.py index d2f3227d0..e56272312 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 c0057f884..c4c324da0 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 `. + + :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 69d551f29..351764225 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 ` + + :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 ` + + :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 ` + + :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 3acef4f49..c7814eea4 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 000000000..bf1691c53 --- /dev/null +++ b/tests/publishers/fixtures/artifactory01.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + true + false + false + false + false + false + false + true + false + false + false + false + true + true + false + false + false + false + +
+ test + http://artifactory.example.net/artifactory + libs-release-local + libs-snapshot-local + + None + +
+ + + + + + + + +
+
+
diff --git a/tests/publishers/fixtures/artifactory01.yaml b/tests/publishers/fixtures/artifactory01.yaml new file mode 100644 index 000000000..45e77bcc6 --- /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 000000000..064c9ac97 --- /dev/null +++ b/tests/publishers/fixtures/artifactory02.xml @@ -0,0 +1,49 @@ + + + + + + myfake@email.com + myapp + 1.0 + myfake@email.com + + true + true + true + true + true + true + true + true + false + true + true + true + false + false + true + true + true + true + +
+ test + http://artifactory.example.net/artifactory + libs-release-local + libs-snapshot-local + + None + +
+ + + + + + + + +
+
+
diff --git a/tests/publishers/fixtures/artifactory02.yaml b/tests/publishers/fixtures/artifactory02.yaml new file mode 100644 index 000000000..527cc77ef --- /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 000000000..c1e570e4d --- /dev/null +++ b/tests/wrappers/fixtures/artifactory001.xml @@ -0,0 +1,12 @@ + + + + +
+ test + http://artifactory.example.net/artifactory + repo +
+
+
+
diff --git a/tests/wrappers/fixtures/artifactory001.yaml b/tests/wrappers/fixtures/artifactory001.yaml new file mode 100644 index 000000000..4803cb289 --- /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 000000000..15ce1303b --- /dev/null +++ b/tests/wrappers/fixtures/artifactory002.xml @@ -0,0 +1,24 @@ + + + + +
+ test + http://artifactory.example.net/artifactory + release-repo + snapshot-repo +
+ *.zip=>results + libs-release-local:prod/*=>prod-jars + custom_prop=${PROJECT_ENV_VAR} + true + true + true + true + + PROJECT_*,ORG_* + + +
+
+
diff --git a/tests/wrappers/fixtures/artifactory002.yaml b/tests/wrappers/fixtures/artifactory002.yaml new file mode 100644 index 000000000..4604b15af --- /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 000000000..def8794ae --- /dev/null +++ b/tests/wrappers/fixtures/artifactory003.xml @@ -0,0 +1,70 @@ + + + + +
+ test + http://artifactory.example.net/artifactory + + + + false + + + + + false + + +
+ + test + http://artifactory.example.net/artifactory + + + + false + + + + + false + + + + + *.zip=>results + + + + PROJECT_*,ORG_* + + + custom_prop=${PROJECT_ENV_VAR} + + + + + + + true + false + false + false + true + false + false + true + false + false + false + false + true + true + false + false + false + false +
+
+
diff --git a/tests/wrappers/fixtures/artifactory003.yaml b/tests/wrappers/fixtures/artifactory003.yaml new file mode 100644 index 000000000..af9f7a844 --- /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_*' +