Pushing freestyle build artifacts to Bitbucket cloud instance

69 views
Skip to first unread message

Ioannis Moutsatsos

unread,
Dec 6, 2017, 5:06:07 PM12/6/17
to Jenkins Users
Greetings;

I need to push build artifacts to a cloud instance of Atlassian Bitbucket.
I've considered the Pubish-to-Bitbucket Jenkins plugin but it does not seem to handle proxies gracefully and fails to connect to the cloud server.

Alternatively, I am considering using a custom groovy build step and the Atlassian Bitbucket REST API  using http-builder-ng to accomplish what is needed.
For example to list my repositories I use:


@Grab('io.github.http-builder-ng:http-builder-ng-core:1.0.3')
import groovyx.net.http.JavaHttpBuilder
import java.net.Proxy
import static groovy.json.JsonOutput.toJson
import static groovyx.net.http.HttpBuilder.configure
import groovy.json.*
def http = JavaHttpBuilder.configure {
    execution
.proxy 'myproxy.net', 20XX, Proxy.Type.HTTP, false
    request
.uri ='https://api.bitbucket.org/2.0/repositories/myusername'
    request
.auth.basic 'myusername','mypass'
   
}.get{
    request
.contentType = 'application/json'
}
JsonOutput.prettyPrint(JsonOutput.toJson(http.toString()))


However, I'm having issues authenticating with this basic authorization strategy

I get the following null result


"{page=1, pagelen=10, size=0, values=[]}"

Any suggestions or alternate strategies?

Thanks
Ioannis
Reply all
Reply to author
Forward
0 new messages