-
[Jenkins] input , parameters , scriptCICD 2023. 1. 27. 00:25
1. input
파이프라인을 진행하는 중에 사용자 입력에 따라 작업을 변경하는 기능
스크립팅 파이프라인
#파이프라인을 중지하고 사용자의 입력을 기다리는 구문 input 'Continue to next stage?' # 'Proceed or Abort' text가 출력되고 선택 후 다음 과정을 진행합니다
Parameter
필수 Parameter
1. message
선택 Parameter
1. id : 외부 처리시 식별자로 사용될 인자
#ID을 이용해 외부 처리 단계를 진행 input id: '{ID 입력}', message: 'Continue to the next stage?' #URL을 통해 Post방식으로 응답 #1 허가 http://[jenkins-base-url]/job/[job_name]/[build_id]/input/{ID 입력}/proceed #2 거절 http://[jenkins-base-url]/job/[job_name]/[build_id]/input/{ID 입력}/abort
2. ok : proceed 대신 제공할 수 있는 선택지
input message: '<message text>', ok: 'Yes'
3. submitter : 응답 권한이 있는 Jenkins 사용자 또는 그룹 지정, 쉼표를 통해 구분하여 여러 사용자 지정 가능
input message: '<message text>', submitter: 'user1,user2'
4. submitterParameter : 환경변수를 통해 parameter 'submitter'를 지정할 수 있다.
input id: 'ctns-prompt', message: 'Continue to the next stage?', submitterParameter: '환경변수'
5. parameters : 사용자의 입력값을 받아 파이프라인에서 인자로 사용 가능
parameter 종류
- string
- text
- booleanParam
- choice
- password
선언적 파이프라인
Parameter
스크립팅 파이프라인과 동일
#example pipeline { agent any stages { stage('Example') { input { message "Should we continue?" ok "Yes, we should." submitter "alice,bob" parameters { string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') } } steps { echo "Hello, ${PERSON}, nice to meet you." } } } }
2. parameters
선언적 파이프라인의 경우 input 구문 밖에서 parameter을 지정하는 것이 가능하다
#example pipeline { agent any parameters { string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') text(name: 'BIOGRAPHY', defaultValue: '', description: 'Enter some information about the person') booleanParam(name: 'TOGGLE', defaultValue: true, description: 'Toggle this value') choice(name: 'CHOICE', choices: ['One', 'Two', 'Three'], description: 'Pick something') password(name: 'PASSWORD', defaultValue: 'SECRET', description: 'Enter a password') } stages { stage('Example') { steps { echo "Hello ${params.PERSON}" echo "Biography: ${params.BIOGRAPHY}" echo "Toggle: ${params.TOGGLE}" echo "Choice: ${params.CHOICE}" echo "Password: ${params.PASSWORD}" } } } }
3. script
선언적 파이프라인이 선언적 스타일을 지원하지 않거나 매우 어려운 렌더링 작업을 수행하는 경우, 선언되지 않은 과정을 진행할 때 script 구문을 사용할 수 있습니다.
참고
일반적으로 script 구문 안에서 정의된 변수들은 script 구문 밖에서 사용할 수 없습니다. script 구문 안에서 정의된 변수를 script 구문 밖에서 사용하기 위해서는 script 구문 안에서 정의하고자 하는 값을 환경 변수 네임스페이스(env)에 할당 해야합니다.'CICD' 카테고리의 다른 글
[Jenkins] Milestone Step Plugin - 여러 빌드가 동일한 Step으로 진입하는 것을 제어 (0) 2023.01.27 [Jenkins] Lockable Resources Plugin - 리소스 동시 사용 제어 (0) 2023.01.27 [Jenkins] 파이프라인 트리거 지정, cron , pollSCM (0) 2023.01.26 [Jenkins] 작업을 실행할 특정 노드를 지정하기 , 연산자를 이용한 노드 지정 , parallel 구문 (0) 2023.01.26 [Jenkins] 파이프라인의 스크립트와 Jenkins 시스템 종류 (0) 2023.01.26