Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven version validation fails when ANSI control sequences are present in the version output #264

Open
zsrv opened this issue Nov 28, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@zsrv
Copy link

zsrv commented Nov 28, 2021

Describe the bug

jfrog-cli-core v2.5.1 introduced validation of the version of Maven that is in use, which is being done by parsing the output of mvn --version. This validation fails if the version line, which is found by searching for a line in the output that starts with "Apache Maven", contains extra characters at the beginning of the line.

The version of Maven that I am using prints the Maven version line in bold, with ANSI control characters at the beginning (and end) of the line.

There is also a related, but secondary, issue where "minSupportedMvnVersion" is not printed correctly (see below).

Example:

user@localhost:~> jfrog config add --interactive=false --url=http://example.com --access-token=x
user@localhost:~> jfrog mvn-config --repo-resolve-releases=x --repo-resolve-snapshots=x --repo-deploy-releases=x --repo-deploy-snapshots=x
[Info] maven build config successfully created.
user@localhost:~> jfrog mvn clean
[Info] Running Mvn...
[Info] Could not get maven version, by running 'mvn --version' command. JFrog CLI mvn commands requires Maven version "+minSupportedMvnVersion+" or higher.
[Error] JFrog CLI mvn commands requires Maven version "+minSupportedMvnVersion+" or higher. The Current version is: 
user@localhost:~> mvn --version
Apache Maven 3.6.3 (SUSE 3.6.3-4.2.1)
Maven home: /usr/share/maven
Java version: 11.0.13, vendor: Oracle Corporation, runtime: /usr/lib64/jvm/java-11-openjdk-11
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.3.18-59.34-default", arch: "amd64", family: "unix"

mvn --version output with control characters visible:

^[[1mApache Maven 3.6.3 (SUSE 3.6.3-4.2.1)^[[m
Maven home: /usr/share/maven
Java version: 11.0.13, vendor: Oracle Corporation, runtime: /usr/lib64/jvm/java-11-openjdk-11
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.3.18-59.34-default", arch: "amd64", family: "unix"

My workaround was to downgrade to JFrog CLI 2.6.1 (which uses jfrog-cli-core 2.5.0).

To Reproduce

Launch openSUSE Leap 15.3 using this image: https://download.opensuse.org/distribution/leap/15.3/appliances/openSUSE-Leap-15.3-JeOS.x86_64-15.3-OpenStack-Cloud-Build9.258.qcow2

# Install Maven
zypper install maven

# Add the JFrog CLI RPM repository
cat > jfrog-cli.repo <<EOF
[jfrog-cli]
name=jfrog-cli
baseurl=https://releases.jfrog.io/artifactory/jfrog-rpms
enabled=1
gpgcheck=0
EOF

zypper addrepo ./jfrog-cli.repo
zypper install jfrog-cli-v2

# Configure
jfrog config add --interactive=false --url=http://example.com --access-token=x
jfrog mvn-config --repo-resolve-releases=x --repo-resolve-snapshots=x --repo-deploy-releases=x --repo-deploy-snapshots=x

# Run the Maven command to observe the error
jfrog mvn clean


# (optional) Downgrade to JFrog CLI 2.6.1
zypper install --oldpackage jfrog-cli-v2=2.6.1-1

# Run the Maven command again, which will now progress
jfrog mvn clean

Expected behavior

JFrog CLI should recognize that I am using Maven version 3.1.0 or above.

Versions

  • JFrog CLI core version: 2.5.1
  • JFrog CLI version (if applicable): 2.6.2
  • Artifactory version: 7.27.10
  • Maven version: Apache Maven 3.6.3 (SUSE 3.6.3-4.2.1)
@zsrv zsrv added the bug Something isn't working label Nov 28, 2021
@sverdlov93
Copy link
Contributor

Hi @zsrv, thanks for reporting this issue and also for the detailed logs.
We managed to reproduce and hopefully fix this issue in #265 PR
The fix may be included in the next release.
We'll keep you updated.

@eyalbe4
Copy link
Contributor

eyalbe4 commented Nov 30, 2021

@zsrv,
Version 2.7.0 includes the fix.
We're looking forward to your feedback for it.

@zsrv
Copy link
Author

zsrv commented Nov 30, 2021

Version 2.7.0 is working for me, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants