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

Compatibility with s4u/maven-settings-action (or any externally configured settings.xml) #59

Open
rj93-finseta opened this issue Nov 14, 2024 · 1 comment

Comments

@rj93-finseta
Copy link

Hi,

I am attempting to refactor our pipelines and I'd like to remove the repositories section from the projects POMs and instead rely on what is configured in single settings.xml that can be used everywhere.

This simplifies our POMs as we have lots of repositories where these repository configuration is duplicated.

I'm using s4u/maven-settings-action to setup the settings.xml file, which by creates /home/runner/.m2/settings.xml

I've tried to configure this action as follows:

uses: qcastel/[email protected]
with:
  m2-home-folder: '/home/runner/.m2'

and in the logs I get:

WARN - No M2 folder '/home/runner/.m2' found. We therefore won't beneficy from the CI cache
Current branch: main
Release branch name: main
We are on the release branch
Using SSH folder /root/.ssh
Using M2 repository folder /home/runner/.m2
ls: /home/runner/.m2: No such file or directory
/home/runner/.m2 is empty, this means we didn't hit a potential M2 cache :(

I've also tried:

- name: Copy settings.xml
   run: |
     mkdir ${{ github.workspace}}/.m2
     cp /home/runner/.m2/settings.xml ${{ github.workspace }}/.m2/settings.xml
     cat ${{ github.workspace }}/.m2/settings.xml

- name: Release
  uses: qcastel/[email protected]
  with:
    m2-home-folder: '${{ github.workspace }}/.m2'

- name: cat settings.xml
  if: always()
  run: |
    cat ${{ github.workspace}}/.m2/settings.xml

Which does seem to then pick up the directory from looking at the logs:

INFO - M2 folder '/github/workspace/.m2' not empty. We therefore will beneficy from the CI cache
Current branch: main
Release branch name: main
We are on the release branch
Using SSH folder /root/.ssh
Using M2 repository folder /github/workspace/.m2

However, that still doesn't seem to work as it is unable to pull any artifacts from custom repositories.

I've tried locally to run mvn -B release:prepare release:perform (after deleting my ~/.m2/repository) with the exact same settings.xml generated by s4u/maven-settings-action, no <repositories> section in my pom.xml and it works fine.

Any ideas how I could get this to work?

@rj93-finseta
Copy link
Author

rj93-finseta commented Nov 14, 2024

I have just noticed that we've also got a distributionManagement section one of our parents, and when I ran it locally it only published the artifacts to the single repository configured there (but picking up credentials from ~/.m2/settings.xml) so potentially there is still something that would need to be set in a pom somewhere in the hierarchy.

Unless you can think theres something I'm missing, as a workaround for my use case I might pivot to a manual script along the lines of (untested):

VERSION=$(mvn ...)
mvn versions:set -DremoveSnapshot
git commit -am "[ci skip] prepare release $VERSION"
git tag $VERSION
mvn deploy -DaltDeploymentRepository=customRepoId::customRepoUrl
mvn versions:set -DnextSnapshot=true
git commit -m "[ci skip] prepare for next development iteration"
git push ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant