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

Publish to multiple repositories? #84

Open
sebersole opened this issue Aug 20, 2015 · 17 comments
Open

Publish to multiple repositories? #84

sebersole opened this issue Aug 20, 2015 · 17 comments

Comments

@sebersole
Copy link

Perhaps I am just missing something in the README, and if so please feel free to point me there..

I have a multi-module build (Hibernate) where I need to be able to publish to 2 separate repositories:

  • a 'maven' repo for publishing the module artifacts
  • a 'generic' repo for publishing dist bundles

But I am completely unsure how to set up this up in the extension.

@cfieber
Copy link

cfieber commented Aug 22, 2015

I have the same use case (a jar module is also packaged as an application and then a deb file using the gradle-ospackage-plugin). The jar should go to a maven repo and the deb to a debian repo

Currently doing some dirty groovy @Delegate action to have two different types of the BintrayExtension / BintrayUploadTask (found several uses of this plugin where extenders are expecting to do project.plugins.getByType or project.extensions.getByType so it doesn't seem particularly safe just to register a second instance of BintrayUploadTask or BintrayExtension)

@cfieber
Copy link

cfieber commented Aug 25, 2015

Ended up not going the @Delegate route, just registering a new instance of BintrayUploadTask that knows how to grab the outputs of the Deb task from the nebula.os-package plugin.

Seems like it could be solved in a cleaner way supporting multiple pkg blocks in BintrayExtension

Here's what I did (as a plugin for our project):

class OspackageBintrayPublishPlugin implements Plugin<Project> {
    @Override
    void apply(Project project) {
        project.plugins.apply(BintrayPlugin)

        //OspackageBintrayExtension just has one attribute (packageRepo):
        def packageExtension = project.extensions.create('bintrayPackage', OspackageBintrayExtension)

        project.tasks.withType(Deb) { Deb deb ->
            def spinnakerDebians = project.configurations.maybeCreate('debians')
            project.artifacts.add('debians', deb)
            def extension = (BintrayExtension) project.extensions.getByName('bintray')

            //this is all copy-n-pasteware from BintrayPlugin except the setting of repoName
            def buildDebPublish = project.tasks.create("publish${deb.name}", BintrayUploadTask) { BintrayUploadTask task ->
                task.with {
                    apiUrl = extension.apiUrl
                    user = extension.user
                    apiKey = extension.key
                    configurations = ['debians']
                    publish = extension.publish
                    dryRun = extension.dryRun
                    userOrg = extension.pkg.userOrg ?: extension.user
                    repoName = packageExtension.packageRepo ?: extension.pkg.repo
                    packageName = extension.pkg.name
                    packageDesc = extension.pkg.desc
                    packageWebsiteUrl = extension.pkg.websiteUrl
                    packageIssueTrackerUrl = extension.pkg.issueTrackerUrl
                    packageVcsUrl = extension.pkg.vcsUrl
                    packageLicenses = extension.pkg.licenses
                    packageLabels = extension.pkg.labels
                    packageAttributes = extension.pkg.attributes
                    packagePublicDownloadNumbers = extension.pkg.publicDownloadNumbers
                    versionName = extension.pkg.version.name ?: project.version
                    versionDesc = extension.pkg.version.desc
                    versionReleased = extension.pkg.version.released
                    versionVcsTag = extension.pkg.version.vcsTag ?: project.version
                    versionAttributes = extension.pkg.version.attributes
                    signVersion = extension.pkg.version.gpg.sign
                    gpgPassphrase = extension.pkg.version.gpg.passphrase
                    syncToMavenCentral = extension.pkg.version.mavenCentralSync.sync == null ?
                            true : extension.pkg.version.mavenCentralSync.sync
                    ossUser = extension.pkg.version.mavenCentralSync.user
                    ossPassword = extension.pkg.version.mavenCentralSync.password
                    ossCloseRepo = extension.pkg.version.mavenCentralSync.close
                }
            }
            buildDebPublish.dependsOn(deb)
            buildDebPublish.dependsOn(debians.allArtifacts)
            Upload installTask = project.tasks.withType(Upload)?.findByName('install')
            if (installTask) {
                buildDebPublish.dependsOn(installTask)
            }
            buildDebPublish.group = BintrayUploadTask.GROUP
            project.tasks.publish.dependsOn(buildDebPublish)
        }
    }
}

@dljsjr
Copy link

dljsjr commented Feb 23, 2016

I have the exact same use-case as @sebersole; I need to publish the output of a Maven publication to a Maven repo and the output of the Gradle application plugin to a Generic repo. Any update on this?

@sebersole
Copy link
Author

Sorry, I gave up trying to publish to bintray because of this. So no
update on my end :(

On Tue, Feb 23, 2016, 3:53 PM Douglas Stephen [email protected]
wrote:

I have the exact same use-case as @sebersole
https://github.com/sebersole; I need to publish the output of a Maven
publication to a Maven repo and the output of the Gradle application
plugin to a Generic repo. Any update on this?


Reply to this email directly or view it on GitHub
#84 (comment)
.

@itamarb
Copy link

itamarb commented Feb 24, 2016

Adding the capability to publish files to multiple Bintray repositories is on our road-map.
We are currently looking into how this could be implemented and will update this issue on any progress.

Thanks,
Itamar
JFrog Support

@sebersole
Copy link
Author

For what it's worth, I seem to have the problem just with uploading to a
Generic repo. I don't get an error, just that nothing is uploaded.
Different issue I guess, but worth mentioning

On Wed, Feb 24, 2016, 2:06 AM Itamar Berman-Eshel [email protected]
wrote:

Adding the capability to publish files to multiple Bintray repositories is
on our road-map.
We are currently looking into how this could be implemented and will
update this issue on any progress.

Thanks,
Itamar
JFrog Support


Reply to this email directly or view it on GitHub
#84 (comment)
.

@eyalbe4
Copy link
Contributor

eyalbe4 commented Jun 22, 2016

@sebersole, @dljsjr and @cfieber,
This functionality has just been released with 1.7. see the full release notes here

@sebersole
Copy link
Author

Thanks for the work. But as far as I know I am still unable to publish my release bundles (tgz/zip) using this plugin (Generic repo), which is really what I need - see my comment above. This one was a nice to have.

@ollehallin
Copy link

I'm publishing zips and tarballs to a generic repo without problems!

Olle Hallin
[email protected] [email protected]
+46 70 6653071
www. http://www.crisp.se/hit.se

2016-06-22 17:26 GMT+02:00 Steve Ebersole [email protected]:

Thanks for the work. But as far as I know I am still unable to publish my
release bundles (tgz/zip) using this plugin (Generic repo), which is really
what I need - see my comment above. This one was a nice to have.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#84 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABIXLSyNxIbwDpR8aQw5uq6nE-idr-L-ks5qOVQggaJpZM4FvT8C
.

@sebersole
Copy link
Author

I will try once again with 1.7

@sebersole
Copy link
Author

Still getting error:

  • What went wrong:
    Execution failed for task ':release:bintrayUpload'.

    java.net.SocketException: Broken pipe

@sebersole
Copy link
Author

Tto be clear, that is with 1.7 and Gradle 3m1

@sebersole
Copy link
Author

This is my config:

bintray {
    user = binTrayUser
    key = binTrayApiKey

    publish = true

    filesSpec {
        from "$buildDir/distributions"
        into '/'
    }

    pkg {
        userOrg = 'hibernate'
        repo = 'bundles'
        name = 'hibernate-orm'
    }
}

My version is created: https://bintray.com/hibernate/bundles/hibernate-orm/5.2.1.test

But no files get uploaded...

Caused by: java.net.SocketException: Broken pipe
        at org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:169)
        at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:119)
        at org.apache.http.entity.InputStreamEntity.writeTo(InputStreamEntity.java:102)
        at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:98)
        at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
        at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:122)
        at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:271)
        at org.apache.http.impl.conn.ManagedClientConnectionImpl.sendRequestEntity(ManagedClientConnectionImpl.java:197)
        at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:257)
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
        at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:712)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:517)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1066)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
        at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
        at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:434)
        at groovyx.net.http.HTTPBuilder.request(HTTPBuilder.java:366)
        at groovyx.net.http.HTTPBuilder$request.call(Unknown Source)
        at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure8_closure36.doCall(BintrayUploadTask.groovy:369)
        at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure8.doCall(BintrayUploadTask.groovy:360)
        at com.jfrog.bintray.gradle.BintrayUploadTask$_bintrayUpload_closure14.doCall(BintrayUploadTask.groovy:461)
        at com.jfrog.bintray.gradle.BintrayUploadTask.bintrayUpload(BintrayUploadTask.groovy:460)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        ... 75 more

@sebersole
Copy link
Author

So what I have seem to have found is that filesSpec does not seem to work, at least for me. I changed that to use configurations instead and it started working.

The plugin documentation I think is maybe just wrong or unclear.

@sebersole
Copy link
Author

And any idea what this might mean? "Configuration(s) specified but the install task does not exist in project :release."

@sebersole
Copy link
Author

Still struggling getting this plugin to work :)

So here is where I am at. I have the following:

configurations {
    bundles {
        description = 'Configuration used to group the archives output from the distribution plugin.'
    }
}

artifacts {
    // distTar and distZip the 2 tasks added for me by the Gradle distribution plugin
    bundles distTar
    bundles distZip
}


bintray {
    user = binTrayUser
    key = binTrayApiKey

    publish = true

    configurations = ['bundles']

    pkg {
        userOrg = 'hibernate'
        repo = 'bundles'
        name = 'hibernate-orm'

        version {
            name = project.version
            desc = "The ${project.version} release of the Hibernate ORM project"
        }
    }
}

For testing I switched my local project version to 5.2.1.test. My $buildDir/distributions directory contains the 2 5.2.1.test archives (zip and tgz) as well as the 2 5.2.1-SNAPSHOT archives.

As I understand it, that bundles configuration object ought to contain just the 2 5.2.1.test files. And in fact printing it shows that.

This plugin uploads the 2 5.2.1.test archives. But it eventually fails with:

* What went wrong:
Execution failed for task ':release:bintrayUpload'.
> Could not publish 'hibernate/bundles/hibernate-orm/5.2.1-SNAPSHOT': HTTP/1.1 404 Not Found [message:Version '5.2.1-SNAPSHOT' was not found]

I have no idea where this plugin/task is getting 5.2.1-SNAPSHOT.

@sebersole
Copy link
Author

Strangely it just started working. I swear I did not make any changes :)

Anyway, I am currently not publishing the Maven artifacts to Bintray so I can not comment on the plugin working to publish to 2 BinTray repos simultaneously. But it does now seem to be working (albeit in a touchy way) to publish to a generic repo, which I was not able to do previously - I did have to change to use configurations rather than filesSpec to get it to work though.

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

6 participants