Search code examples
jenkinsartifactory

adding Artifactory.newServer to jenkins pipeline


I would like to instantiate a an instance of a Artifactory.newServer object in a jenkins pipeline. This object is instantiated like so

def rtServer = Artifactory.newServer url: SERVER_URL, credentialsId: CREDENTIALS

My question is where do I set the SERVER_URL and CREDENTIALS in jenkins. The documentation on the jenkins plugin does elaborate on this: https://www.jfrog.com/confluence/display/JFROG/Configuring+Jenkins+Artifactory+Plug-in, but I need some help understanding how to reference the environment variables in the Jenkins file itself. I am using a simple pipeline job. Any help with this would be much appreciated.


Solution

  • The correct way to instantiate a server object is like so

    rtServer = Artifactory.newServer url: 'server', username: username , password: password
    

    To set this up properly you'll need to go to Manage Jenkins select the artifactory plugin and create a new artifactory server. After I did that everything worked just fine.