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] Find snapshot metadata in nested pom #3728

Closed
jgarec opened this issue May 16, 2019 · 24 comments
Closed

[maven] Find snapshot metadata in nested pom #3728

jgarec opened this issue May 16, 2019 · 24 comments
Labels
auto:reproduction A minimal reproduction is necessary to proceed manager:maven Maven (Java) package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others stale status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality

Comments

@jgarec
Copy link
Contributor

jgarec commented May 16, 2019

What would you like Renovate to be able to do?
Being able to update to latest snapshot which could be newer than the latest release.

Describe the solution you'd like
By default, update to latest release but for some dependencies that are explictly described in config file, update to latest snapshot if available.

Describe alternatives you've considered

Additional context
In debug logs, i can see that snapshots are identified as "newer versions" but when renovate try to download it, there is an error because snapshot and release repositories have not the same structure (multiple artifacts for the same snapshot versions). This download fails so renovate considers that this version is unavailable :

DEBUG: Url not found http://xxxxx/repository/xxxxxx/yyyyyyy/artifact-name/5.1.22-SNAPSHOT/artifact-name-5.1.22-SNAPSHOT.pom

Release repository structure :
image

Snapshot repository structure :
image
In this case, i think renovate should download another maven-metadata and identify the right artifact to download.

@rarkins
Copy link
Collaborator

rarkins commented May 16, 2019

I don’t fully understand your request, sorry. Can you provide more details including examples and logs if possible? What type of Maven registry is it?

@rarkins rarkins added manager:maven Maven (Java) package manager needs-requirements labels May 16, 2019
@jgarec
Copy link
Contributor Author

jgarec commented May 17, 2019

Our repositories are hosted on nexus3 (i don't if the same problem occurs with artifactory).

We have 3 maven repositories :

  • one for snapshots (hosted / maven 2 format / allow redeploy)
  • one for private (hosted / maven 2 format / disable redeploy)
  • one containing both repositories (group / maven 2 format), called : group-repository

Use case :
I have an application called myapp, with a dependency called mylib.
myapp use latest release : 5.1.21

here is an extract of maven-metadata.xml for mylib :

<metadata modelVersion="1.1.0">
  <groupId>groupid</groupId>
  <artifactId>mylib</artifactId>
  <versioning>
    <latest>5.1.22-SNAPSHOT</latest>
    <release>5.1.21</release>
    <versions>
      <version>5.0.0</version>
      <version>5.0.1</version>
      <version>5.0.2</version>
      <version>5.0.3</version>
      <version>5.0.4</version>
      <version>5.0.5</version>
      <version>5.1.20</version>
      <version>5.1.21</version>
      <version>5.1.22-SNAPSHOT</version>
    </versions>
    <lastUpdated>20190517040006</lastUpdated>
  </versioning>
</metadata>

Log file :

DEBUG: Found 1 repositories for groupid.mylib (repository=gitgroup/myapp)
DEBUG: Looking up groupid.mylib in repository #0 - http://foo/nexus3/repository/group-repository/ (repository=gitgroup/myapp)
DEBUG: Found 40 new versions for groupid.mylib in repository http://foo/nexus3/repository/group-repository/ (repository=gitgroup/myapp)
DEBUG: Found 40 versions for groupid.mylib (repository=gitgroup/myapp)
DEBUG: Url not found http://foo/nexus3/repository/group-repository/groupid/mylib/5.1.22-SNAPSHOT/mylib-5.1.22-SNAPSHOT.pom (repository=gitgroup/myapp)
DEBUG: groupid.mylib not found in repository http://foo/nexus3/repository/group-repository/ (repository=gitgroup/myapp)

when renovate try to download mylib-5.1.22-SNAPSHOT.pom, a 404 error occurs because it doesn't exist (the structure of a snapshot directory is different).

@jgarec
Copy link
Contributor Author

jgarec commented May 17, 2019

Versions Maven plugin works well in this case :

mvn versions:display-dependency-updates shows no update available
mvn versions:display-dependency-updates -DallowSnapshots=true finds one update :

[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   groupid:mylib ............ 5.1.21 -> 5.1.22-SNAPSHOT

but renovate is not able to find this update.

@rarkins
Copy link
Collaborator

rarkins commented May 17, 2019

Have you set "ignoreUnstable": false in your config (or with a package rule just for that one package)? It looks like it's failing earlier than that though, but you would need that setting as it's like the "allowSnapshots" equivalent.

@jgarec
Copy link
Contributor Author

jgarec commented May 17, 2019

Sorry i didn't know this flag but it's only a part of the solution.

I've made a simple test : force the result of pomContent if pomContent is undefined when calling downloadMavenXml :

async function getDependencyInfo(dependency, repoUrl, version) {
    const result = {};
    const path = `${version}/${dependency.name}-${version}.pom`;
    const pomContent = await downloadMavenXml(dependency, repoUrl, path);
    if (!pomContent)
        return {homepage:'foo',sourceUrl:'bar'};
//        return result;

    const homepage = pomContent.valueWithPath('url');
    if (homepage && !containsPlaceholder(homepage)) {
        result.homepage = homepage;
    }
    const sourceUrl = pomContent.valueWithPath('scm.url');
    if (sourceUrl && !containsPlaceholder(sourceUrl)) {
        result.sourceUrl = sourceUrl;
    }
    return result;
}

async function getDependencyInfo(dependency, repoUrl, version) {

  • With this modification + ignoreUnstable: true => merge request is not created
  • With this modification + ignoreUnstable: false => merge request is created
Package Update Change References
groupid:mylib patch 5.1.21 -> 5.1.22-SNAPSHOT homepage, source

@rarkins
Copy link
Collaborator

rarkins commented May 17, 2019

So right now, if we cannot find homepage or sourc eurl then we return {} and then the version is actually ignored?

@jgarec
Copy link
Contributor Author

jgarec commented May 17, 2019

Yes, if the pom file is unavailable (to extract homepage / sourceurl) then it fails.

i think it should :

This new maven-metadata.xml looks like :

<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
  <groupId>groupid</groupId>
  <artifactId>mylib</artifactId>
  <version>5.1.22-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <timestamp>20190516.193217</timestamp>
      <buildNumber>145</buildNumber>
    </snapshot>
    <lastUpdated>20190517040006</lastUpdated>
    <snapshotVersions>
      <snapshotVersion>
        <extension>pom</extension>
        <value>5.1.22-20190516.193217-145</value>
        <updated>20190516193217</updated>
      </snapshotVersion>
    </snapshotVersions>
  </versioning>
</metadata>

@rarkins
Copy link
Collaborator

rarkins commented May 17, 2019

Sounds good, thanks.

@rarkins rarkins added ready type:bug Bug fix of existing functionality and removed needs-requirements labels May 17, 2019
@jgarec
Copy link
Contributor Author

jgarec commented May 17, 2019

Finally, it seems that switching from ignoreUnstable: true to ignoreUnstable: false was the solution.
But i forgot to check the box "" to update the current MR ...
so .... it works perfectly ...

The only bug is that it can't find the sourceurl and homepage but i'm not sure it's necessary to add more complexity just for snapshots MR.

So if you're ok with that, we can close this "issue"

@rarkins
Copy link
Collaborator

rarkins commented May 18, 2019

I would still like to keep this open but will rename it so that we learn to capture the pom for the snapshot too. Thanks.

@rarkins rarkins changed the title [maven] Update to latest snapshot dependency if available [maven] Find snapshot metadata in nested pom May 18, 2019
@rarkins rarkins added the priority-4-low Low priority, unlikely to be done unless it becomes important to more people label May 18, 2019
@rarkins rarkins removed the ready label Jun 18, 2020
@jgarec
Copy link
Contributor Author

jgarec commented Sep 30, 2020

Hi @rarkins @zharinov, FYI :
Since #5614 and because of this bug, It's no longer possible to get snapshots (with ignoreUnstable=false flag).

The current workaround is to use RENOVATE_EXPERIMENTAL_NO_MAVEN_POM_CHECK flag.

@rarkins
Copy link
Collaborator

rarkins commented Oct 1, 2020

@jgarec can you summarize for us:

  1. What files/data are published for snapshots vs stable releases?
  2. Do you know if doing so is valid according to any spec, or would it be considered incomplete?

@jgarec
Copy link
Contributor Author

jgarec commented Oct 1, 2020

  1. Release vs Snapshot :
  • Release repository structure :
    image

  • Snapshot repository structure :
    image
    Requires to download another maven-metadata and identify the right snapshot to download (because it could contains snapshot version 142 143 144 ; this screenshot only show one) .

When this issue was opened, it was necessary to download the pom file of the snapshot to get the url of the project / the homepage ... but now, renovate is able to find this with the latest release published :

const latestVersion = getLatestStableVersion(releases);
if (latestVersion) {
repoForVersions[latestVersion] = repoUrl;
}

So i wonder if we could just consider that using unstable versions doesn't require to check that the pom is valid and available ?

@rarkins rarkins added priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others and removed priority-4-low Low priority, unlikely to be done unless it becomes important to more people labels Oct 1, 2020
@rarkins
Copy link
Collaborator

rarkins commented Oct 1, 2020

If the pom file is there, then what leads you to need to skip the pom check altogether?

@bpfoster
Copy link
Contributor

I believe I'm seeing the same issue as @jgarec. The maven datasource checks for presence of the pom via a URL like http://repo.com/groupId/myLib/5.1.22-SNAPSHOT/myLib-5.1.22-SNAPSHOT.pom in filterMissingArtifacts().

As you can see from his screenshots, the repository doesn't store a -SNAPSHOT file, instead only the timestamped files (5.1.22-SNAPSHOT/myLib-5.1.22-20190515.193717-144.pom).

So the isHttpResourceExists() in filterMissingArtifacts() returns false, and the version is filtered out.

@olegkrivtsov
Copy link
Contributor

I'd like to take this one.

@rarkins rarkins removed the priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others label Dec 3, 2021
@rarkins rarkins added the auto:reproduction A minimal reproduction is necessary to proceed label Dec 3, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2021

Hi there,

Help us by making a minimal reproduction repository.

Before we can start work on your issue we first need to know exactly what's causing the current behavior. A minimal reproduction helps us with this.

To get started, please read our guide on creating a minimal reproduction to understand what is needed.

We may close the issue if you (or someone else) have not provided a minimal reproduction within two weeks. If you need more time, or are stuck, please ask for help or more time in a comment.

Good luck,

The Renovate team

@rarkins rarkins added priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:requirements Full requirements are not yet known, so implementation should not be started and removed status:ready labels Dec 3, 2021
@rarkins
Copy link
Collaborator

rarkins commented Dec 3, 2021

Actually this one needs a reproduction first

@github-actions
Copy link
Contributor

When a bug has been marked as needing a reproduction, it means nobody can work on it until one is provided. In cases where no reproduction is possible, or the issue creator does not have the time to reproduce, we unfortunately need to close such issues as they are non-actionable and serve no benefit by remaining open. This issue will be closed after 7 days of inactivity.

@github-actions github-actions bot added the stale label Dec 18, 2021
@catostrophe
Copy link

It seems that #11327 doesn't fix this issue. Still can't update -SNAPSHOT deps without setting RENOVATE_EXPERIMENTAL_NO_MAVEN_POM_CHECK.

@rarkins
Copy link
Collaborator

rarkins commented Dec 22, 2021

Needs reproduction

@catostrophe
Copy link

It turned out even RENOVATE_EXPERIMENTAL_NO_MAVEN_POM_CHECK didn't work out.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2022

When a bug has been marked as needing a reproduction, it means nobody can work on it until one is provided. In cases where no reproduction is possible, or the issue creator does not have the time to reproduce, we unfortunately need to close such issues as they are non-actionable and serve no benefit by remaining open. This issue will be closed after 7 days of inactivity.

@github-actions github-actions bot added the stale label Jan 6, 2022
@github-actions
Copy link
Contributor

This bug report has been closed as we need a reproduction to work on this. If the original poster or anybody else with the same problem discovers that they can reproduce it, please create a new issue, and reference this issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto:reproduction A minimal reproduction is necessary to proceed manager:maven Maven (Java) package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others stale status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality
Projects
None yet
Development

No branches or pull requests

5 participants