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

jfrog cli error "M2_HOME is not set" in GitHub action/workflow #975

Open
leemeador opened this issue Feb 19, 2021 · 5 comments
Open

jfrog cli error "M2_HOME is not set" in GitHub action/workflow #975

leemeador opened this issue Feb 19, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@leemeador
Copy link

Describe the bug
This notice for GitHub workflow/action virtual runners says the M2_HOME env variable is no longer getting set: actions/runner-images#2600

Unfortunately, the command below fails with an error saying it is required:

jfrog rt mvn clean install --batch-mode -s settings.xml mavenBuildConfig.yaml --build-name=my_build --build-number=0.0.1-SNAPSHOT

Error message: Error: M2_HOME environment variable is not set

To Reproduce
Run the command above in a github action/workflow. (But I haven't tried it in a scaled down workflow.)

Expected behavior
It should run maven

Screenshots
If applicable, add screenshots to help explain your problem.

Versions

  • JFrog CLI version: jfrog version 1.44.0
  • JFrog CLI operating system: Ubuntu 20.04
  • Artifactory Version: n/a

Additional context
Add any other context about the problem here.

@leemeador leemeador added the bug Something isn't working label Feb 19, 2021
@leemeador
Copy link
Author

When I add this to a previous step in the workflow, it does not fail:

echo "M2_HOME=/usr/share/apache-maven-3.6.3" >> $GITHUB_ENV

@eyalbe4
Copy link
Contributor

eyalbe4 commented Feb 19, 2021

@leemeador,
Having the M2_HOME environment variable set has always been a requirement of the jfrog rt mvn command. Nothing changed on JFrog CLI.
I assume something changed on the workflow that runs the command. I understand that adding the env var resolves the issue.

@leemeador
Copy link
Author

@eyalbe4 Exactly. Thanks for the quick reply.

That's why I included the link to GitHub's issue where they were removing M2_HOME.

I'm asking for you guys to change JFrog CLI to not need M2_HOME so that we don't have to set it and everyone that is new to writing actions doesn't have to search all over the internet to not find any info about it. I do know that lots of maven related tools do not use that variable OR maybe they use it if its there and do something else if its missing.

@msunkrish
Copy link

@eyalbe4 - this issue of CLI expecting M2_HOME is seriously affecting us. Is there a fix in progress?

@tonyford80249
Copy link

It may be that the image you are using doesn't have maven installed or that M2_HOME needs to be set. Here is what I did to fix the issue.

.artifactory:

image: $ARTIFACTORY_IMAGE

stage: deploy

services:

- docker:dind

before_script:
# Install curl
- export DEBIAN_FRONTEND=noninteractive
# Configure Artifactory instance
- jfrog c add artifactory --artifactory-url=$JFROG_ARTIFACTORY_URL --access-token $JFROG_ARTIFACTORY_ACCESS_TOKEN --interactive=false
# Configure maven
- apt update
- apt -y install maven
- mvn -v
- echo "$M2_HOME"
- export M2_HOME=/usr/share/maven
- echo "$M2_HOME"

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

4 participants