jfrog / artifactory-gradle-plugin

JFrog Gradle plugin for Build Info extraction and Artifactory publishing.
Apache License 2.0
21 stars 15 forks source link

How does the plugin get configuration information from the JFrog CLI? #47

Closed prestontim closed 6 months ago

prestontim commented 1 year ago

How can we help?

I have a question about the JFrog CLI in respect to how it's integrated with Gradle. When I'm executing a GitHub Action, I am running the steps shown here:

image

My question: When I'm executing the "jf gradle" command, do I have access inside Gradle (in an extension or something) to what is set via the "--repo-deploy" switch passed to the "jf gradle-config" command? I'm trying to get access to this information for an in-house plugin that I'm currently working on.

I've launched both the JFrog CLI and Gradle with debug logging and nothing is really jumping out at me.

Thanks for your time!

yahavi commented 1 year ago

@prestontim, When you use jf gradle, the JFrog CLI injects the Gradle Artifactory plugin using a Gradle init script. This plugin is responsible for gathering the publication and extracting deployment candidates. Eventually, the complete artifacts and build-info are sent for publication to Artifactory.

If you could provide more details about your goal, I could offer you a more precise answer.

prestontim commented 1 year ago

@yahavi, Thanks for getting back to me!

What I'm trying to accomplish is to update an existing in-house plugin that needs access to what the Artifactory plugin is using for the deployment repository. In the past (on Jenkins), we'd configured this via a custom project property (-PARTIFACTORY_REPO=<deploy repo name>). The project property is easy to get access to in our plugin code: IMG_8363

On Github, we're using the JFrog CLI for this configuration (line 106 in the original screenshot), so I'm unsure how I can get access to this information.

Hopefully that makes a little more sense.

yahavi commented 1 year ago

@prestontim Appreciate you sharing the use case. I'm a bit uncertain about whether you're aiming to configure the repository key for the Gradle Artifactory plugin or if your goal is to retrieve the repository key.

From the provided screenshot, it appears that you're attempting to establish the deployment repository, distinguishing between snapshot and release. The plugin's code already handles the decision-making process for deploying to either repository, depending on the deployment path. For instance, if the path contains "-SNAPSHOT," the deployment is directed to the snapshot repository. You can check the implementation here: PublicationUtils.java#L406.

That being said, there's still a bit of fine-tuning needed before we can roll out this feature completely. You can take a look at the necessary adjustments here: https://github.com/yahavi/artifactory-gradle-plugin/commit/2bb42350daa11001a4adab2e89dea0d41ddd5374.

Example:

publish {
  repository {
    releaseRepoKey = 'libs-release-local'
    snapshotRepoKey = 'libs-snapshot-local'
  }
}

If we were to implement this feature, would it fulfill your requirements? Thanks!

yahavi commented 6 months ago

@prestontim In Gradle Artifactory plugin v5.2.0 we added the above functionality of configuring release and snapshot repositories. Feel free to use it and share your feedback with us.