2016-09-09 2 views
5

을 Artifactory하는 Jenkinsfile을 설정하는 방법 나는 이런 내 jenkinsfile했습니다 :업로드 받는다는 이슈

properties([[$class: 'GitLabConnectionProperty', gitLabConnection: '[email protected]']]) 
node { 
    env.JAVA_HOME = tool 'JDK 7' 
    def mvnHome = tool 'Maven 3.2.2' 
    def nodeJS = tool 'IA_NodeJS' 
    env.PATH = "${mvnHome}/bin:${nodeJS}/bin:${env.JAVA_HOME}/bin:${env.PATH}" 

    stage ('checkout') { 
    checkout scm 
    } 

    stage ('build') { 
    gitlabCommitStatus("build") { 
     // your build steps 
     sh 'mvn clean install -Denv=dev -P !faster' 
    } 
    } 

    stage ('upload') { 
    gitlabCommitStatus("upload") { 
     def server = Artifactory.server "[email protected]" 
     def buildInfo = Artifactory.newBuildInfo() 
     buildInfo.env.capture = true 
     buildInfo.env.collect() 

     def uploadSpec = """{ 
     "files": [ 
      { 
      "pattern": "**/target/*.jar", 
      "target": "libs-snapshot-local" 
      }, { 
      "pattern": "**/target/*.pom", 
      "target": "libs-snapshot-local" 
      }, { 
      "pattern": "**/target/*.war", 
      "target": "libs-snapshot-local" 
      } 
     ] 
     }""" 
     // Upload to Artifactory. 
     server.upload spec: uploadSpec, buildInfo: buildInfo 

     buildInfo.retention maxBuilds: 10, maxDays: 7, deleteBuildArtifacts: true 
     // Publish build info. 
     server.publishBuildInfo buildInfo 
    } 
    } 
} 

이 방법은 업로드 유물없이 "Maven의 스타일"레이아웃 (패키지 하위 폴더 및 리딩를) 만들 젠킨스.

"Maven3-Artifactory Integration"이 선택된 상태에서 정상 작업과 같이 업로드 된 결과물을 artifactory에 업로드하려고합니다.

+0

왜'mvn deploy'를 사용하지 않습니까? – khmarbaise

+0

나는'mvn deploy'없이 만들어진 jenkinsfile로 작업을 변환하고있다. 나는 화환을 변경하지 않고 그것을 변환하고 싶습니다. @ khmarbaise가 가능하지 않다면, 나는 짐을 바꿀거야 – TeoMatthew

답변

16

Artifactory Jenkins 플러그인 버전 2.7.2에서 Artifactory pipeline DSL을 사용하여 Maven 및 Gradle을 실행할 수 있습니다. 같을 것이다 새로운 DSL을 빌드 스크립트를 사용

:

def server = Artifactory.server "[email protected]" 
    def buildInfo = Artifactory.newBuildInfo() 
    buildInfo.env.capture = true 
    def rtMaven = Artifactory.newMavenBuild() 
    rtMaven.tool = MAVEN_TOOL // Tool name from Jenkins configuration 
    rtMaven.opts = "-Denv=dev" 
    rtMaven.deployer releaseRepo:'libs-release-local', snapshotRepo:'libs-snapshot-local', server: server 
    rtMaven.resolver releaseRepo:'libs-release', snapshotRepo:'libs-snapshot', server: server 

    rtMaven.run pom: 'pom.xml', goals: 'clean install', buildInfo: buildInfo 

    buildInfo.retention maxBuilds: 10, maxDays: 7, deleteBuildArtifacts: true 
    // Publish build info. 
    server.publishBuildInfo buildInfo 

당신은 jenkins-pipeline-examples 더 Artifactory 파이프 라인 DSL의 예를 찾을 수 있습니다.

+0

고마워, 정확히 내가 원하는거야! 버그 또는 기능 요청을 github에 제출할 수 있습니까? – TeoMatthew

+1

버그 리포트 또는 기능 요청을 위해서는 [Jenkins Artifactory Plugin Jira] (https://www.jfrog.com/jira/projects/HAP/issues)를 통해 의사 소통하는 것이 더 좋습니다. Jenkins Artifactory Plugin은 오픈 소스 프로젝트이므로 [jenkins-artifactory-plugin] (https://github.com/JFrogDev/jenkins-artifactory-plugin) 프로젝트에 끌어 오기 요청을 전송하여 코드를 작성할 수 있습니다. –