jfrog / jenkins-artifactory-plugin

Jenkins artifactory plugin
http://jenkins-ci.org/
116 stars 188 forks source link

Artifactory download for LATEST builds does not work with version 3.3.2 #180

Open MarcelAtEricsson opened 5 years ago

MarcelAtEricsson commented 5 years ago

hi,

I use this spec: "files": [ { "pattern": "proj-dsc-test-generic-local/Builds/Build-check-DSC-Master-CPT/dsc*", "recursive": "false", "build": "Builds :: Build-check-DSC-Master-CPT/LATEST",
"explode": "false" }

this does not find any builds :(

I removed the complete "build" line, then I find 4 files (2 files per build). when I use: build": "Builds :: Build-check-DSC-Master-CPT", I find nothing when I use: build": "Builds :: Build-check-DSC-Master-CPT/5, I find 2 files of builds #5

Also when I switch to the old method, downloading LATEST is not working.

julianobst commented 3 years ago

I ran into the same Problem. Is this still open or does an solution exist?

eyalbe4 commented 3 years ago

Hi @julianobst, Will you be able to share some details about your case? If you can provide steps to reproduce this issue, it'll be great.

julianobst commented 3 years ago

Hi @eyalbe4, I'm using scripted pipelines and the Artifactory plugin version 3.10.4 on my test Jenkins.

First of all, I have succesfully uploaded some dummy files to my Artifactory test server with the following Jenkins script:

stage("Upload") {
        def uploadSpec = """{
            "files": [
                {
                    "pattern": ".*example\\.(bin|hex|elf)",
                    "target": "build.generic-local/UploadArtifacts_Test/${env.BUILD_NUMBER}",
                    "flat": "false",
                    "regexp": "true"
                }
            ]
        }"""
        println uploadSpec
        def buildInfo = this.server.upload spec: uploadSpec, failNoOp : true
        server.publishBuildInfo buildInfo
        println buildInfo
    }

I run the script multiple times to get a bunch of builds and artifacts on the Artifactory. Afterwards I tried to download only the latest build artifacts (in my case build number 13) with the following script:

stage("Download latest artifacts") {
        sh '''rm ./* -R -f'''
        def downloadSpec = """{
            "files": [
                {
                    "pattern": "build.generic-local",
                    "target": "./",
                    "build": "UploadArtifacts_Test/LATEST",
                    "flat": "false",
                    "recursive": "true"
                }
            ]
        }"""
        println downloadSpec
        server.download spec: downloadSpec, failNoOp: true
        sh '''ls -R'''
    }

Which failed with

Searching for artifacts...
[...]
java.io.IOException: Failed to retrieve build artifacts report: HTTP/1.1 400 Bad Request

Next try with

stage("Download latest artifacts") {
        sh '''rm ./* -R -f'''
        def downloadSpec = """{
            "files": [
                {
                    "pattern": "build.generic-local",
                    "target": "./",
                    "build": "UploadArtifacts_Test",
                    "flat": "false",
                    "recursive": "true"
                }
            ]
        }"""
        println downloadSpec
        server.download spec: downloadSpec, failNoOp: true
        sh '''ls -R'''
    }

Which also failed with

Searching for artifacts...
[...]
java.io.IOException: Failed to retrieve build artifacts report: HTTP/1.1 400 Bad Request

At least I tried:

stage("Download latest artifacts") {
        sh '''rm ./* -R -f'''
        def downloadSpec = """{
            "files": [
                {
                    "pattern": "build.generic-local",
                    "target": "./",
                    "build": "UploadArtifacts_Test/13",
                    "flat": "false",
                    "recursive": "true"
                }
            ]
        }"""
        println downloadSpec
        server.download spec: downloadSpec, failNoOp: true
        sh '''ls -R'''
    }

Which succeeds with

[...]
Searching for artifacts...
Found 1 artifacts.
Beginning to resolve Build Info published dependencies.
[...]

May this helps for reproduce the issue.

julianobst commented 3 years ago

@eyalbe4 any updates? Could you reproduce the behavior?