2017-12-05 4 views
1

파이프 라인을 실행할 때 userInput이 필요합니다. 입력은 특정 저장소의 자식 분기입니다. jenkins 작업에서 git 매개 변수를 구성 할 수 있으므로 jenkins 파이프 라인에서 어떻게 구성해야합니까? >젠킨스 파이프 라인에 git 매개 변수 추가

stage 'promotion' 
    def userInput = input(
    id: 'userInput', message: 'Let\'s promote?', parameters: [ 
    [$class: 'GitParameterDefinition', description: 'Environment', name: 'env',type: 'Branch'], 
    [$class: 'TextParameterDefinition', defaultValue: 'uat1', description: 'Target', name: 'target'] 
]) 
    echo ("Env: "+userInput['env']) 
    echo ("Target: "+userInput['target']) 

내가 할 모든 내가 파이프 라인 자체에 자식 저장소와 그것을 구성 어떻게 빈 입력 박스를 다음과 같이 나는 파이프 라인의 코드를 가지고있다.

+0

당신은 사용자의 입력에서 얻은 지점 이름에 따라 약간의 저장소를 복제하려고? – TrafLaw

+0

@PrasadMarne 예 올바른 –

+0

입력 유형으로 GitParameterDefinition을 사용할 수 없습니다. 그래서 나는 당신이하고 싶은 것을 성취하는 다른 방법을 게시했습니다. 희망이 당신을 돕는다. – TrafLaw

답변

0

당신은 다음과 그것을 할 수 있습니다 :

node { 
stage ('input') { 

    def userInput = input message: 'enter git details', 
    parameters: [ 
    string(defaultValue: 'dev', description: 'branch name', name: 'branch'), 
    string(defaultValue: '', description: 'repo url', name: 'url') 
    ] 

    git branch: userInput['branch'], credentialsId: 'creds', url: userInput['url'] 
    } 
} 
+0

이것은 문자열 입력으로 브랜치를 요구할 것이고, 브랜치가 git에서 자동으로 검색되기를 원할 것이다. 나는 실제로 액티브 선택 플러그인을 추가하여 그것을 얻었으며 여기에 단계를 추가했다 : https://apassionatechie.wordpress.com/2017/12/06/jenkins-pipeline-git-branch-as-parameter/ –

+0

나는 당신의 질문을 생각한다. "입력은 특정 저장소의 git 브랜치가 될 것입니다" – TrafLaw

+0

예 저장소가 파이프 라인에 추가되지만 브랜치는 동적으로 검색되어야합니다 –

관련 문제