Accessing MavenLocal from Actions

I’m trying to set up an Actions workflow for a gradle project. I want to upload mavenLocal as a build artifact from the first job and download it in the second (which is a matrix). However, the actions/upload-artifact Action can’t seem to find mavenLocal: I keep getting this warning from the upload stage:

Warning: No files were found with the provided path: ~/.m2/repository/. No artifacts will be uploaded.

I tried to test by adding a stage of

ls ~/.m2/
ls ~/.m2/repository/

But this fails with:

ls: cannot access '/github/home/.m2/': No such file or directory

Any ideas as to how to access mavenLocal from the jobs? Is it in a non-default path or something?

@Starlight220,

You can try like as this to see if it can work:

  1. Make sure the folder “~/.m2/repository” is not empty and contains the files you need to upload.

  2. Copy the files from “~/.m2/repository” into a folder (My-Artifacts) you create in the workspace (github.workspace).

  3. Upload artifact from the folder My-Artifacts.

For example:

- name: Copy artifact files
  run: |
    mkdir -p My-Artifacts
    cp -r ~/.m2/repository/* My-Artifacts

- name: Upload artifact
  uses: actions/upload-artifact@v2
  with:
    name: artifact-name
    path: My-Artifacts

Thanks for the suggestion.
However I tried and it failed:

  mkdir -p MyArtifacts
  cp -r ~/.m2/repository/* MyArtifacts
  ls MyArtifacts
  shell: sh -e {0}
cp: cannot stat '/github/home/.m2/repository/*': No such file or directory
Error: Process completed with exit code 1.

Any other ideas, or ideas as to why this failed?

@Starlight220,

I tried to test by adding a stage of
ls ~/.m2/
ls ~/.m2/repository/

You also can try “ls -R ~” to see if the folder .m2 exists.

In addition, if possible, you can share your repository with us so that we can check more detailed configurations in your workflow to analyze the root cause.

Nvm, found out that a Docker container messed up the home directory - without the container the workflow worked as expected.