Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins and gradle artifactory integration -- authentication

I am not clear on how I can publish from a Jenkins server to Artifactory without committing my credentials in gradle.properties. I have been reading over the wiki and forums, but nothing seems to address this (or I missed it).

We have a shared Jenkins server and my project uses gradle. I would like to deploy to my artifacts to a specific repo (linked to my artifactory logon account) on artifactory. I can deploy using my local machine, since I have my artifactory_user, artifactory password, and artifactory contextUrl values set in gradle.properties.

Without committing my artifactory credentials, how do I deploy from our Jenkins server?

I thought I could use the Gradle-Artifactory integration plugin and use the "Override default deployer credentials" option to specify my credentials on the Jenkins UI and it would override (or set) my Artifactory username and password, but that does not appear to work.

I always get the error in my build:

15:36:52 A problem occurred evaluating root project 'TCS-master-CI'.
15:36:52 Could not find property 'artifactory_user' on root project 'TCS-master-CI'

.

So what does the Gradle Artifactory Integration provide me? Is there something in the build code I need to do to make this work correctly?

Do I need to specify the gradle.properties somewhere on the shared Jenkins Server?

I would appreciate anybodys help.

Thanks.

like image 216
Jason K. Avatar asked Feb 11 '23 03:02

Jason K.


1 Answers

This is how you can publish from a Jenkins server to Artifactory without committing the credentials in gradle.properties:

artifactory {
  publish {
    repository {
      username = project.hasProperty('artifactory_user') ? project.artifactory_user : System.getenv()['ARTIFACTORY_USER']
      password = project.hasProperty('artifactory_password') ? project.artifactory_password, : System.getenv()['ARTIFACTORY_KEY']
    }
  }
}
like image 87
JBaruch Avatar answered Feb 15 '23 09:02

JBaruch