Search code examples
jenkinsjenkins-pluginsjenkins-pipelineartifactoryjfrog-cli

Upload file to JFrog from Jenkinsfile


I am currently trying to upload a file to my artifactory (JFrog), I have the following code:

script{
def server = Artifactory.server 'jfrog1'
def uploadSpec = """{
    "files": [
        {
            "pattern": "hola.txt",
            "target": "libs-release-local/"
        }
    ]
}"""
server.upload(uploadSpec)

}

However the file does not reach my artifactory and Jenkins does not give an error.

Help and Thanks.


Solution

  • Can You find file hola.txt directly in workspace? If not try use **/*

    server = Artifactory.server 'Artifactory'
    def uploadSpec = """{
        "files": [
        {
        "pattern": "**/target/*.war",
        "target": "releases/${APP_REPO}/${version.trim()}/"
        }
        ]}"""
    server.upload(uploadSpec)
    

    Above example work correctly.