2013-03-02 2 views
1

문제점 : SVN 변경 목록을 얻는 데 사용하는 그루비 스크립트가 있습니다. 나는 이것을 실행한다. 실행 Groovy 스크립트. 변경 세트를 얻는 데 도움이되는 Hudson 객체에 접근 할 수 있기 때문에. 이제는 슬레이브 컴퓨터에서 변경된 설정 만 체크 아웃하려고합니다. 배치 스크립트 (슬레이브에 있음)를 준비하고 SVN URL을 하나씩 변경 세트에서 전달하여 호출하려고 시도했습니다.이 스크립트는 저에게 맞지 않습니다.젠킨스 슬레이브에있는 batch/groovy 스크립트를 "Execute system Groovy script"에서 호출하는 방법은 무엇입니까?

import hudson.model.* 
import hudson.util.* 
import hudson.scm.* 

// work with current build 
def build = Thread.currentThread()?.executable 
def changeItems = build.changeSet.items 
def changes = [] 
changes += changeItems as List 
changes.each { item -> 
println("changes") 
item.paths.each{ fileEntry -> 
fileEntry.value ---->Pass this to script so It can be checked out in slave m/c. 
} 
} 

질문 : - 위의 문제를 해결하는 방법은 없나요? - 젠킨스에서 변경 세트의 SVN URL을 명령 행 콘솔로 전달할 수 있습니까? 당신이 당신의 SVN 저장소를 폴링하거나 설명하겠다 here로 SVN 트리거가 - 은 나에게 젠킨스 작업을 트리거한다

답변

0

뭔가 도와주세요. 두 가지에서

당신은 구성

  • 소스 코드 - 관리로 작업을 시작 : 서브
  • 체크 아웃 전략 : 가능

만큼 사용 'SVN 업데이트' 그런 다음 Groovy 시스템 스크립트를 시작하십시오.

import hudson.model.* 
import hudson.util.* 
import hudson.scm.* 

// work with current build 
// (does only work as groovy system script, not in the Jenkins shell) 
def build = Thread.currentThread()?.executable 

// for testing, comment the line above and uncomment the job line 
// and one of the build lines - use specific build (last build or build by number) 
//def job = hudson.model.Hudson.instance.getItem("<your job name>") 
//def build = job.getLastBuild() 
//def build = job.getBuildByNumber(162) 

// get ChangesSets with all changed items 
def changeSet= build.getChangeSet() 
def items = changeSet.getItems() 

그러나이 단계에서 파일은 다음과 같습니다. 빌드 머신에서 준비! changeSet에는 svn 업데이트에 포함 된 모든 항목이 포함되어 있습니다. 따라서 경로를 사용하여 처리하십시오. 예를 들어 변경된 파일 당 Jenkins 작업을 다음과 같이 시작할 수 있습니다.

void startJenkinsJob(jobName, param) 
{ 
    // Start another job 
    def job = Hudson.instance.getJob(jobName) 
    def anotherBuild 
    try { 
     def params = [ 
      new StringParameterValue('StringParam', param), 
     ] 
     def future = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params)) 
     println "Waiting for the completion of " + HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName) 
     anotherBuild = future.get() 
    } catch (CancellationException x) { 
     throw new AbortException("${job.fullDisplayName} aborted.") 
    } 
    println HyperlinkNote.encodeTo('/' + anotherBuild.url, anotherBuild.fullDisplayName) + " completed. Result was " + anotherBuild.result 

    // Check that it succeeded 
    build.result = anotherBuild.result 
    if (anotherBuild.result != SUCCESS && anotherBuild.result != UNSTABLE) { 
     // We abort this build right here and now. 
     throw new AbortException("${anotherBuild.fullDisplayName} failed.") 
    } 
} 
관련 문제