magnayn / Jenkins-Repository

Jenkins Maven Repository Plugin
20 stars 38 forks source link

how do I use plugin with gradle #24

Open veonua opened 9 years ago

veonua commented 9 years ago

my best guess was

artifacts { archives jarFile }

uploadArchives { repositories { mavenDeployer { repository(url: System.getenv("Jenkins.Repository")) pom.project { licenses { license { name 'Testing' url 'http://test.com' distribution 'repo' } } } } } }

but server error:

rtyler commented 8 years ago

I naively tried the same thing that @veonua tried in order to get Gradle-based builds to use the plugin.

From my cursory read of the code, there is nothing that I've seen which would support an actual upload of an artifact.

It's not clear to me whether this enhancement request is something @magnayn wants to see in this GitHub Issues or in the Jenkins JIRA though

magnayn commented 8 years ago

So..

The original repository plugin was deeply integrated with the jenkins maven project type. A maven build instrumented by jenkins adds the artifacts that are built into the build, (objects of class MavenArtifactRecord) which then gives you various download links.

The repository plugin looks for the same artifacts, and presents them in a maven-consumable format. Thus there was no need to 'upload' anything, as all artifacts would be automagically exposed. This was done to a) be much faster than having to upload Gbs of data to a nexus repository and b) so you get 'one repository per build' behaviour.

If your build isn't a maven project type, there are no artifacts declared, so nothing available in the downloads. This is annoying, because if you want to use 'freestyle' builds (or, better: workflow builds), artifacts are no longer available.

The fix I have for "maven, but executed via freestyle" is to add an extra plugin into the maven build, that 'reports back' to Jenkins (via a very stupid web interface) files as they are built (path + naming metadata) which then adds the relevant records into the jenkins job and exposes them once again to maven.

This is in -master, we're using it in production but it's a little rough around the edges.

For gradle you could do something similar. You need to figure out how to tell jenkins/repository 'what artifact exists where in the tree. You could theoretically get it to support uploading in the way described, but there wouldn't be that much point over just running a simple nexus/artifactory instance..

On Mon, Nov 2, 2015 at 3:43 PM, R. Tyler Croy notifications@github.com wrote:

I naively tried the same thing that @veonua https://github.com/veonua tried in order to get Gradle-based builds to use the plugin.

From my cursory read of the code, there is nothing that I've seen which would support an actual upload of an artifact.

It's not clear to me whether this enhancement request is something @magnayn https://github.com/magnayn wants to see in this GitHub Issues or in the Jenkins JIRA though

— Reply to this email directly or view it on GitHub https://github.com/magnayn/Jenkins-Repository/issues/24#issuecomment-153057587 .

rayzr522 commented 7 years ago

@magnayn Some documentation for the freestyle project tool would be great. I'm forced to use the freestyle project type due to a bug with Jenkins on OpenShift. I realize this issue has been inactive for quite a while, but my team really needs this. Am I just missing something? Is there any place that demonstrates how to use this?

magnayn commented 7 years ago

I don't think I have anything public (it was hacked in in order to jump to freestyle). That said, I think what you need to do is -

(I do this in a parent pom so it gets applied to all children).

That plugin itself is hosted within the repository on Jenkins - so either you need to add it to your POM (or we just added jenkins repository to our nexus instance so it was available)

What you should see is artifacts being 'reported' to jenkins. I think you also need to trigger the updaterpublisher after the build is completed (which walks the list of reported artefacts and archives them) - there should be a UI thing for builds, or I think

step([$class: 'UpdaterPublisher']);

from a Jenkinsfile.

rayzr522 commented 7 years ago

To be honest, I only understood half of that. I don't know a ton about Jenkins, my team just needed one for giving people beta versions of our software.

What exactly did you mean by "make sure the nodes in your POM are correct with the jenkins URL"? I'm not entirely sure how I'm supposed to be linking this project to my Jenkins server.

Other than that though, I just put that plugin into the POM of the project I want deployed to Maven, right? And then I add step([$class: 'UpdaterPublisher']); somewhere, but where exactly should I put this? And when you said "UI thing for builds", are you referring to the post-build action, "Publish Maven Artifacts"?

Sorry for inconveniencing you like this, I just don't know much about the inner workings of Jenkins. Any help you could provide me would be greatly appreciated.

rayzr522 commented 7 years ago

@magnayn Alright, so I believe I understand all of this except for how I'm supposed to link the project to the Jenkins server. What exactly does "make sure the nodes in your POM are correct with the jenkins URL" mean?