[RTFACT-16969] CLONE Distributing a docker build to Bintray fails with REST API Created: 18/Jun/18  Updated: 22/Jun/18  Resolved: 22/Jun/18

Status: Resolved
Project: Artifactory Binary Repository
Component/s: None
Affects Version/s: None
Fix Version/s: 6.0.0

Type: Bug Priority: Normal
Reporter: Matthew Wang Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File curl.txt     Text File jenkins.txt    

 Description   

Distributing a docker build to Bintray fails with REST API (or using the jenkins DSL) has issues:

Steps to reproduce:

-create distribution repo, use default rules

-create a docker build

-try to use https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-DistributeBuild or https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins#WorkingWithPipelineJobsinJenkins-DistributingBuildArtifacts for the build.

-see that the API errors out (see curl.txt and jenkins.txt). The curl request seems to distribute to Bintray with a partial success (you see the image in the bintray repo), however using the Jenkins API completely fails.

-Workaround: add docker.repoName and docker.manifest properties to all layers of the artifacts in the build



 Comments   
Comment by Matthew Wang [ 22/Jun/18 ]

Retrying on Artifactory 6.0 results in a different error. With below pipeline script:

node {

def buildInfo = Artifactory.newBuildInfo()

def artifactoryServer = Artifactory.server "Artifactory1"
def artifactoryDocker = Artifactory.docker server: artifactoryServer

// but let's make sure we are definitely logged into artifactory's DTR using those same credentials through withCredentials

sh 'docker login docker-local.artifactory.test -u admin -p password'
sh 'docker tag busybox docker-local.artifactory.test/busybox:2'
artifactoryDocker.addProperty("docker.repoName", "busybox")
artifactoryDocker.addProperty("docker.manifest", "2")
buildInfo = artifactoryDocker.push 'docker-local.artifactory.test/busybox:2', 'docker-local'
//artifactoryDocker.pull("docker-local.artifactory.test/busybox:latest", buildInfo)
buildInfo.env.collect()
artifactoryServer.publishBuildInfo buildInfo

def artServer = Artifactory.server "Artifactory1"
/*
def arturl = "http://localhost:8081/artifactory/"
def curlstr = "curl -uadmin:password ${arturl}"
def distribStr = curlstr + "api/build/distribute/${env.JOB_NAME}/${env.BUILD_NUMBER} -X POST -H 'Content-Type: application/json' "
//def distribStr = curlstr + "api/build/distribute/dockerpipeline/30 -X POST -H 'Content-Type: application/json' "

def dockerDistrib = distribStr +
"-d '

{" + " \"publish\" : \"true\"," + " \"overrideExistingFiles\" : \"true\"," + " \"async\" : \"false\"," + " \"targetRepo\" : \"dist-test\"," + " \"dryRun\" : \"false\"" + "}

'"
println "DOCKERDISTRIB: " + dockerDistrib
sh dockerDistrib
*/

def distributionConfig = [
'buildName' : buildInfo.name,
'buildNumber' : buildInfo.number,
'targetRepo' : 'dist-test',
'publish' : true,
'overrideExistingFiles': true,
'async' : false,
//'sourceRepos' : [repo],
'dryRun' : false
]
print distributionConfig
artServer.distribute distributionConfig

}

 

Fails with:

ERROR: Distribution failed. View Artifactory logs for more details: HTTP/1.1 409 Conflict
Distribution of dist-test #34 encountered errors: Error distributing docker-local/busybox/2/sha256_8c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a -> registry/busybox/2/busybox/2/sha2568c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a: Illegal manifest.json path: busybox/2/sha256_8c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a, Aborting push of tag.

 

Using REST API instead of docker pipeline dsl results in similar errors:
"message" : "Distribution of dist-test #20 encountered errors: Error distributing docker-local/busybox/2/sha256_8c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a -> registry/busybox/2/busybox/2/sha2568c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a: Illegal manifest.json path: busybox/2/sha256_8c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a, Aborting push of tag.",

 

 

Generated at Sun Oct 20 12:01:32 UTC 2019 using JIRA 7.6.16#76018-sha1:9ed376192612a49536ac834c64177a0fed6290f5.