2013-08-12 2 views
1

내가 essentally 한 빌드가 foo/*/bar/*.xml 일치하는 각 파일에 대해 실행하고자하는 멀티 구성 빌드를위한 그루비 축 플러그인에 바인딩됩니다. 나는 GroovyAxis 플러그인이 좋은 적합 할 것이라고 생각하지만, 나는 빌드 구성 스크립트 내에서 액세스 할 수있는 방법에 대한 문서를 찾을 수 없습니다, 그래서 어디서든 작업 공간 디렉토리를 읽을 수 없습니다.변수 프로젝트 구성은 젠킨스

return new File('.').listFiles().collect{it.toString()}과 같이 실행하면 서버의 루트 디렉토리에있는 모든 파일이 반환됩니다.

누구나 올바른 방향으로 나를 가리킬 수 있습니까?

+0

이것을 알아 냈습니까? – ottago

답변

0

알아내는 데 시간이 걸렸지 만 여기에 해결책이 있습니다. Groovy 스크립트는 마스터에서 실행되므로 FilePath를 사용하여 슬레이브의 파일에 액세스해야합니다.

import hudson.FilePath 

def workspace = context?.build?.workspace 

if (null == workspace) { 
    return ['noworkspace'] // avoid returning 'default' so the user has a chance of figuring out what went wrong 
} 

def configDir = workspace.toString() + '/openpower/configs/' 

def dir = new FilePath(workspace.channel, configDir) 

def files = [] 
dir.list().each { 
    def name = it.getName() 
    if (name.endsWith('_defconfig')) { 
     files << name.replace('_defconfig', '') 
    } 
} 

return files