2017-02-16 1 views
0

Jenkins 파이프 라인 플러그인을 사용하여 프로젝트를 테스트하고 있습니다. 내가 master로 병합 할 기능 지점이있을 때노드에서 작업을 두 번 실행하십시오.

node { 

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

    stage("build") { 
    //some other code 
    } 

    stage("SonarQube Analysis") { 
    //some other code 
    } 

} 

, 내가 먼저 기능에, master에이 과정을하고 있는지보고 싶다 : 나는 다음과 같은 형식의 그루비 스크립트가 SonarQube 분석은 기능이 더 나쁩니다.

def codeCoverageMaster = node("master") 
def codeCoverageFeature = node("feature/someFeature") 
if(codeCoverageFeature < codeCoverageMaster) { 
    currentBuild.result = "ERROR" 
} 

이 가능한 같은 것입니다 : 나는 이런 종류의 일을하고 싶은

? 당신은 당신의 스크립트를 포함하고 SonarQube 결과를 반환하는 함수를 정의하여 그것을 할

답변

1

, 당신은 두 번 함수를 호출하고 결과 비교 :

def runBranch(String path) { 
    def sonarQubeRes 
    node { 

    stage("checkout") { 
     //some other code 
     // Use path supplied to this function 
    } 

    stage("build") { 
     //some other code 
    } 

    stage("SonarQube Analysis") { 
     //some other code 
    } 

    } 
    return sonarQubeRes 
} 

def codeCoverageMaster = runBranch("master") 
def codeCoverageFeature = runBranch("feature/someFeature") 
if(codeCoverageFeature < codeCoverageMaster) { 
    currentBuild.result = "ERROR" 
} 
관련 문제