- Create Artifactory account
- Generate an access token with username (username must be your email id)
- Add username and password under jenkins credentials
- Install Artifactory plugin
- Update Jenkinsfile with jar publish stage
def registry = 'https://valaxy01.jfrog.io' stage("Jar Publish") { steps { script { echo '<--------------- Jar Publish Started --------------->' def server = Artifactory.newServer url:registry+"/artifactory" , credentialsId:"artifactory_token" def properties = "buildid=${env.BUILD_ID},commitid=${GIT_COMMIT}"; def uploadSpec = """{ "files": [ { "pattern": "jarstaging/(*)", "target": "libs-release-local/{1}", "flat": "false", "props" : "${properties}", "exclusions": [ "*.sha1", "*.md5"] } ] }""" def buildInfo = server.upload(uploadSpec) buildInfo.env.collect() server.publishBuildInfo(buildInfo) echo '<--------------- Jar Publish Ended --------------->' } } }
Check-point: Ensure below are update
- your jfrog account details in place of
https://valaxy01.jfrog.io
in the defination of registrydef registry = 'https://valaxy01.jfrog.io'
- Credentials id in the place of
jfrogforjenkins
in thedef server = Artifactory.newServer url:registry+"/artifactory" , credentialsId:"artifactory_token"
- Maven repository name in the place of
libs-release-local
in the"target": "ttrend-libs-release-local/{1}",