0
votes

In the below code:

def server = Artifactory.server 'server_id';

def uploadSpec = """{
                "files": [{
                    "pattern": "${WORKSPACE}/$repoName/target/$repoName-0.1-$jarType.jar",
                    "target": "libs-release-local/a/b/c/"
                    }
                    ]
            }"""

server.upload(uploadSpec)    

server.upload(uploadSpec) does not create repository path a/b/c under libs-release-local, when ran for the first time


Jenkins is connect to Artifactory with admin privileges

1) Why above code does not create repository path to upload artifact in Artifactory?

2) Does server.upload internally use JFrog cli?

2
How to diagnose the problem? Jenkins does not show any error in Console output after running server.upload(uploadSpec) - overexchange

2 Answers

0
votes

1) The path will be created under the repository only if an artifact is uploaded. If no error occurred and the path was not created, I am assuming the pattern did not find any match and no artifacts were uploaded.

As to your comment, you can diagnose the problem by setting 'failNoOp' to true, which will fail the build if no files are affected:

server.upload(uploadSpec, true) 

The Console Output would also contain a line as "Deploying artifact: /path/to/artifact" for every artifact uploaded.

2) No, the Jenkins Artifactory Plug-in does not rely on JFrog CLI at all.

-1
votes

you can use the jfrog's REST API for this: https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API

and use curl to put your artifact.

eg.

sh("curl -u username:password@ -X PUT \"${mavenRepo}/${relativeMavenPath}/${serviceName}/${serviceTag}/${serviceName}-${serviceTag}.jar\" -T services.jar")