From bdeb63e5791e03173080f2b1b35de2f6520b6a96 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2020 22:22:14 +0100 Subject: [PATCH] maven_artifact: Adjust path for time stamped SNAPSHOT versions (#713) (#1318) * Adjust path for time stamped SNAPSHOT versions Test the version string for the timestamp SNAPSHOT pattern. If it matches, substitute the SNAPSHOT version in the artifact path rather than the timestamped version string. * Add changelog fragment for PR 713 * Update changelogs/fragments/713-maven-timestamp-snapshot.yml Co-authored-by: Felix Fontein * C Fix problems reported by shippable Fix problems reported by pull request checks * Resolve additional shipping errors Co-authored-by: jweber Co-authored-by: Felix Fontein (cherry picked from commit 9787e8a6bf4698248d17be1de5e9a61d76ad2b54) Co-authored-by: John Weber --- changelogs/fragments/713-maven-timestamp-snapshot.yml | 2 ++ plugins/modules/packaging/language/maven_artifact.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/713-maven-timestamp-snapshot.yml diff --git a/changelogs/fragments/713-maven-timestamp-snapshot.yml b/changelogs/fragments/713-maven-timestamp-snapshot.yml new file mode 100644 index 0000000000..1b308bbcfa --- /dev/null +++ b/changelogs/fragments/713-maven-timestamp-snapshot.yml @@ -0,0 +1,2 @@ +bugfixes: +- "maven_artifact - handle timestamped snapshot version strings properly (https://github.com/ansible-collections/community.general/issues/709)." diff --git a/plugins/modules/packaging/language/maven_artifact.py b/plugins/modules/packaging/language/maven_artifact.py index edd7078b45..03c3d4d44f 100644 --- a/plugins/modules/packaging/language/maven_artifact.py +++ b/plugins/modules/packaging/language/maven_artifact.py @@ -215,6 +215,7 @@ import shutil import io import tempfile import traceback +import re from ansible.module_utils.ansible_release import __version__ as ansible_version from re import match @@ -307,7 +308,11 @@ class Artifact(object): def path(self, with_version=True): base = posixpath.join(self.group_id.replace(".", "/"), self.artifact_id) if with_version and self.version: - base = posixpath.join(base, self.version) + timestamp_version_match = re.match("^(.*-)?([0-9]{8}\\.[0-9]{6}-[0-9]+)$", self.version) + if timestamp_version_match: + base = posixpath.join(base, timestamp_version_match.group(1) + "SNAPSHOT") + else: + base = posixpath.join(base, self.version) return base def _generate_filename(self):