Thursday, April 23, 2020

Jenkins pipeline code to upload artifacts to Artifactory

node {

    def server
    def buildInfo
    def rtMaven
    def mvnHome = tool 'Maven3'

stage ("checkout")  {
   //checkout code
}

  stage ('Artifactory configuration') {
    server = Artifactory.server('My_Artifactory');
    rtMaven = Artifactory.newMavenBuild()
    rtMaven.tool = 'Maven3'
    rtMaven.deployer releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local', server: server
    rtMaven.resolver releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot', server: server
    rtMaven.deployer.deployArtifacts = false // Disable artifacts deployment during Maven run

    buildInfo = Artifactory.newBuildInfo()
  }
  
   stage ('Build') {
        rtMaven.run pom: 'MyWebApp/pom.xml', goals: 'install', buildInfo: buildInfo
    }
   
    stage ('Upload Artifacts') {
        rtMaven.deployer.deployArtifacts buildInfo
       server.publishBuildInfo buildInfo
    }
}


No comments:

Post a Comment

What is GitHub Advanced Security for Azure DevOps | Configure GitHub Advanced Security for Azure DevOps

GitHub Advanced Security for Azure DevOps brings the  secret scanning, dependency scanning  and  CodeQL code scanning  solutions already ava...