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

API-breaking changes with org.jfrog.buildinfo:build-info-extractor-gradle:latest.release #745

Open
NicolasRouquette opened this issue Jun 29, 2023 · 23 comments
Labels
bug Create a report to help us improve

Comments

@NicolasRouquette
Copy link

Describe the bug
A clear and concise description of what the bug is.

The gradle-artifactory-plugin doc
recommends using the plugin with the latest.release version like this:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
  }
}
apply plugin: "com.jfrog.artifactory"

Further down the page, the doc shows a template for the plugin configuration that begins like this:

artifactory {
  +contextUrl = 'http://repo.myorg.com/artifactory'  

Since the publication of version 5.0.0 on 2023-06-29 (today), we now have a strange behavior with an error like this:

> Could not set unknown property 'contextUrl' for extension 'artifactory' of type org.jfrog.gradle.plugin.artifactory.config.ArtifactoryPluginConvention.

This occurs in a gradle script like this:

ext {
   jpl_imce_artifactory_url = "...'
}
artifactory {
  contextUrl = jpl_imce_artifactory_url // Gradle reports an error at this line.
  ...
}

It seems that version 5.0.0 introduces an incompatible configuration paradigm that makes the current documentation based on version 4.x obsolete.

Furthermore, I cannot even find any source code corresponding to org.jfrog.gradle.plugin.artifactory.config.ArtifactoryPluginConvention

To Reproduce
Steps to reproduce the behavior

See above.

Expected behavior
A clear and concise description of what you expected to happen.

Version 5.0.0 should be backwards compatible with previous versions of the gradle artifactory plugin.

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

Versions

  • Extractor version:
  • Operating system:
  • Artifactory Version:

Additional context
Add any other context about the problem here.

@NicolasRouquette NicolasRouquette added the bug Create a report to help us improve label Jun 29, 2023
@NicolasRouquette
Copy link
Author

On Maven central, https://central.sonatype.com/artifact/org.jfrog.buildinfo/build-info-extractor-gradle/5.0.0/versions, I see this:

image

I was shocked that all of our projects that use the Artifactory plugin do not work unless I change the version from latest.release to 4.33.1.

@DanielJRutledge
Copy link

DanielJRutledge commented Jun 30, 2023

I was pretty shocked to see this too, now all of our builds are broken as we're referencing latest.release as well. It looks like this brand-new repo did published 5.0.0: https://github.com/jfrog/artifactory-gradle-plugin; it's not clear to me whether that was intentional.

@jessejcollins
Copy link

@NicolasRouquette - Thank you for opening this Issue! I've been having this same issue on some new build servers, and I was pulling my hair out thinking it was an issue with the new servers.

@DanielJRutledge - Agreed. The release of 5.0.0 feels unintentional. As of writing this, https://plugins.gradle.org/plugin/com.jfrog.artifactory still shows 4.33.1 as the latest version despite 5.0.0 being deployed to Maven.

In case it helps others, as mentioned, the temp fix was to specify an explicit dependency upon 4.33.1 instead of latest.release:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.33.1"
  }
}

@eyalbe4
Copy link
Contributor

eyalbe4 commented Jun 30, 2023

All -
Versions 5 does include breaking changes. We used a major version for this release because it introduces breaking changes.
This release is actually a complete rewrite of the plugin from Groovy to Java. This major change is a prerequisite for multiple upcoming improvements and new support for important Gradle features.
Please use the latest 4 release for your builds.

@DanielJRutledge
Copy link

@eyalbe4 All of us are using the latest.release tag per Jfrog's recommendation. Would it be possible to make the 5.x releases pre-release so that we can elect to move over when appropriate?

@NicolasRouquette
Copy link
Author

@eyalbe4 Since the API-breaking changes are intentional in Version 5, shouldn't this be documented?

Until this happens, the current documentation for the plugin version, latest.release, has become factually wrong.

@jessejcollins
Copy link

jessejcollins commented Jun 30, 2023

@eyalbe4

Was there ever any communications about the upcoming breaking changes for 5.x?

Why is the documentation for 5.x still showing contextUrl?
https://github.com/jfrog/artifactory-gradle-plugin/blob/7ab3e871096dbae82da6a5552ea5227de3103a33/README.md#%EF%B8%8F-artifactory-configuration

Where's the documentation on how to use the 5.x version of the plugin?

Should the 5.x version of the plugin not be used at this time? If not, why has it been published to Maven?

Does this pull request mean that contextUrl will be usable for version 5.x in the future?
jfrog/artifactory-gradle-plugin#32

Without prior communication, it might sound like an easy switch to point at the latest 4.x release, but it is tedious when organizations have hundreds/thousands of repos using this plugin, each with many feature branches.

@eyalbe4
Copy link
Contributor

eyalbe4 commented Jul 1, 2023

All -
We wrongly assumed people were using the latest 4 version (4+) as part of their Gradle scripts. Let us check internally the best way to move forward and share an update here.

@DanielJRutledge
Copy link

What's the update here? It looks like the team is releasing 5.0.1 and is just plowing ahead. This is extremely destructive to users and builds as we weren't given any notice of required changes.

@yahavi
Copy link
Member

yahavi commented Jul 5, 2023

Hi @DanielJRutledge version 5.0.1 includes jfrog/artifactory-gradle-plugin#32 which should help mitigating this issue.
Do you still encounter issues in 5.0.1?

@DanielJRutledge
Copy link

The new plugin still requires Gradle 6.9, which as others have noted on this thread, was a requirement rolled out without any notice.

@NicolasRouquette
Copy link
Author

@yahavi With 5.0.1, I still get the same errors as initially reported. This is with Java 17 and Gradle 7.5.1.

@jessejcollins
Copy link

With Java 11, Gradle 7.4.1, and 5.0.1 of the Artifactory Gradle Plugin, I no longer get the Could not set unknown property 'contextUrl' error immediately when executing my build.gradle. But when the publish task (artifactoryPublish) is executed I'm getting the following error now:

> startup failed:
  build file '/my/path/build.gradle': 208: unable to resolve class org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails 
   @ line 208, column 11.
               for (org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails details : deployDetailsSet) {
               ^

@DanielJRutledge
Copy link

DanielJRutledge commented Jul 6, 2023

We wrongly assumed people were using the latest 4 version (4+) as part of their Gradle scripts. Let us check internally the best way to move forward and share an update here.

@eyalbe4 We need to know what the approach for this library is going to be; it doesn't seem like this was intended to be release in this fashion, and there are multiple known issues at this point. Do we plan to have latest.release point to 4.x instead?

@attiasas
Copy link
Contributor

attiasas commented Jul 6, 2023

Hi @jessejcollins, We moved back some package and classes to their previous places to mitigating similar issues. version 5.0.2 includes jfrog/artifactory-gradle-plugin#36 which should help mitigating this.
Do you still encounter issues in 5.0.2?

@jessejcollins
Copy link

Hi @attiasas - I'm getting this error with 5.0.2:

Execution failed for task 'artifactoryPublish'.
> Could not get unknown property 'helperPublications' for task 'artifactoryPublish' of type org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask.

This error occurred after a few files were successfully published to Artifactory. These successfully published files were not occurring for 5.0.0 or 5.0.1, so there is some progress.

@attiasas
Copy link
Contributor

Hey @jessejcollins, Glad to see we have progress.
This inner class was removed in the major version, did you access 'helperPublications' manually in the build script?
can you share the error running the task with -stacktrace / -d so I can get more context of this issue?

@jessejcollins
Copy link

OK, you are right. This comes from the configuration in our build.gradle file.

Our CI/CD pipeline injects code into the build.gradle for a hook to the Artifactory plug-in using doLast, and that injected code uses the helperPublications class.

The usage of the helperPublications class is to get the Artifactory repository where the artifact will be published (which is used later in the pipeline for other processing - e.g. checking Xray scan results after publication).

Here's a modified snippet of the injected Gradle task:

tasks.withType(org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask) {
  doLast {
    String artifactRepo = ""
    HashSet deployDetailsSet = helperPublications.artifactDeployDetails
    if (!deployDetailsSet.isEmpty()) {
      for (org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails details : deployDetailsSet) {
        artifactRepo = details.deployDetails.targetRepository
        if (!artifactRepo.equals("")) {
          break
        }
      }
    }
    println(artifactRepo)
  }
}

Is there a new equivalent class/method for the 5.0.* version of the Artifactory plug-in that contains similar artifact deployment details as helperPublications.artifactDeployDetails?

@attiasas
Copy link
Contributor

attiasas commented Jul 10, 2023

ArtifactoryTask wil now directly return it usinggetDeployDetails() (after the task took action)
So probably the following snippet is what you are looking for:

tasks.withType(org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask) {
    doLast {
        String artifactRepo = ""
        HashSet deployDetailsSet = getDeployDetails()
        if (!deployDetailsSet.isEmpty()) {
            for (org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails details : deployDetailsSet) {
                artifactRepo = details.deployDetails.targetRepository
                if (!artifactRepo.equals("")) {
                    break
                }
            }
        }
        println(artifactRepo)
    }
}

let us know if there are any other migration issues

@jessejcollins
Copy link

Thank you @attiasas!

Using getDeployDetails() worked great for the 5.* version of the plugin.

We've updated the injected code to the following so it works for both the 4.* & 5.* plugin:

tasks.withType(org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask) {
  doLast {
    String artifactRepo = ""
    HashSet deployDetailsSet = null
    try {
      // ARTIFACTORY PLUGIN 4.0.0+
      deployDetailsSet = helperPublications.artifactDeployDetails
    } catch (Exception e) {
      // ARTIFACTORY PLUGIN 5.0.0+
      deployDetailsSet = getDeployDetails()
    }
    if (!deployDetailsSet.isEmpty()) {
      for (org.jfrog.gradle.plugin.artifactory.extractor.GradleDeployDetails details : deployDetailsSet) {
        artifactRepo = details.deployDetails.targetRepository
        if (!artifactRepo.equals("")) {
          break
        }
      }
    }
    println(artifactRepo)
  }
}

@NicolasRouquette
Copy link
Author

It would be nicer if we did not rely on an exception to handle the different versions.

@DanielJRutledge
Copy link

It looks like the conclusion is to keep 5.x as the latest. Is there any documentation on breaking changes besides the minimum Gradle verison?

@attiasas
Copy link
Contributor

Hi @DanielJRutledge, there is a section about it in the README.md at the overview section.
You can also check out the configuration section for a full descriptions about the supported configuration options.

maggi373 added a commit to Thorfusion/Mekanism-Community-Edition that referenced this issue Oct 18, 2023
Rollback jfrog.buildinfo to v4.33.1 due to breaking changes in v5.0.0
reference: jfrog/build-info#745

REF: #136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Create a report to help us improve
Projects
None yet
Development

No branches or pull requests

6 participants