본문 바로가기

개발

Jenkins Robot Framework Project Pipeline Script Sample

728x90

Jenkins 에서 Robot Framework Project 를 Pipeline 으로 구성 하고 싶은 경우가 있다.

이 경우 아래 처럼 스크립트를 작성하면 된다. Robot Framework 프로젝트를 pipeline 으로 구성하는 방법은 아래처럼 maven 으로 감싸서 실행하는 방법과 shell 명령어를 직접 구성하는 방법이 있다.

 

지금은 maven 으로 감싸는 샘플 코드만 남아 있어서 이것만 먼저 정리해 보았다.

 

 

Maven 으로 Robot Framework 를 구성한 경우

node {
    def mvnHome = tool 'M3'
    stage('Preparation') { // for display purposes
    
    if (isUnix()) {
       bat(/"${mvnHome}\bin\mvn" clean/)
       bat(/"git" reset --hard/)
    } else {
       sh(/"${mvnHome}/bin/mvn" clean/)
       sh(/"git" reset --hard/)
    }  
    git branch: '[Branch Name]', credentialsId: '[CredentialID]', url: '[Git Repo URL]' 
   } 
   
   stage('GUI TEST') {
    if (isUnix()) {
        bat(/"${mvnHome}\bin\mvn" integration-test/)
    } else {
        sh(/"${mvnHome}/bin/mvn" integration-test/)
    }  
   }  
   
   
   stage('Results') {
       publishTestResults()
   }
} 
void publishTestResults() {
    step([
            $class           : 'hudson.plugins.robot.RobotPublisher',
            outputPath       : 'target\\robotframework-report',
            passThreshold    : 100,
            unstableThreshold: 100,
            otherFiles       : '',
            reportFileName   : '**\\*report*.html',
            logFileName      : '**\\*log*.html',
            outputFileName   : '**\\*output*.xml'
    ])
}