DevOps 관리자 또는 개발자는 사용자 인터페이스를 사용하는 대신 YAML 코드를 사용하여 Automation Pipelines에서 파이프라인을 생성하려고 할 수 있습니다. 파이프라인을 코드로 생성하면 코드 편집기를 사용하여 파이프라인 코드에 주석을 삽입할 수 있습니다.
파이프라인 코드에서 환경 변수 및 보안 자격 증명과 같은 외부 구성을 참조할 수 있습니다. 파이프라인 코드에서 사용하는 변수를 업데이트할 때 파이프라인 코드를 업데이트하지 않고 변수를 업데이트할 수 있습니다.
파이프라인 YAML 코드를 템플릿으로 사용하여 다른 파이프라인을 복제 및 생성하고 템플릿을 다른 사용자와 공유할 수 있습니다.
소스 제어 저장소에 파이프라인 코드 템플릿을 저장할 수 있고 이를 통해 버전을 관리하고 업데이트를 추적할 수 있습니다. 소스 제어 시스템을 사용하여 파이프라인 코드를 쉽게 백업하고 필요한 경우 복원할 수 있습니다.
사전 요구 사항
- 코드 편집기가 있는지 확인합니다.
- 소스 제어 저장소에 파이프라인 코드를 저장하려는 경우 작업 인스턴스에 액세스할 수 있는지 확인합니다.
프로시저
결과
코드 예를 사용하여 파이프라인과 끝점을 나타내는 YAML 코드를 생성했습니다.
예: 파이프라인 및 끝점에 대한 YAML 코드 예
이 YAML 코드 예에는 파이프라인의 Automation Pipelines 기본 구축, 단계, 작업, 알림 등에 대한 업무 공간을 나타내는 섹션이 포함되어 있습니다.
지원되는 플러그인에 대한 코드 예는 끝점에 Automation Pipelines 연결 항목을 참조하십시오.
---
kind: PIPELINE
name: myPipelineName
tags:
- tag1
- tag2
# Ready for execution
enabled: false
#Max number of concurrent executions
concurrency: 10
#Input Properties
input:
input1: '30'
input2: 'Hello'
#Output Properties
output:
BuildNo: '${Dev.task1.buildNo}'
Image: '${Dev.task1.image}'
#Workspace Definition
ciWorkspace:
image: docker:maven-latest
path: /var/tmp
endpoint: my-k8s
cache:
- ~/.m2
# Starred Properties
starred:
input: input1
output: output1
# Stages in order of execution
stageOrder:
- Dev
- QA
- Prod
# Task Definition Section
stages:
Dev:
taskOrder:
- Task1, Task6
- Task2 Long, Task Long Long
- Task5
tasks:
Task1:
type: jenkins
ignoreFailure: false
preCondition: ''
endpoints:
jenkinsServer: myJenkins
input:
job: Add Two Numbers
parameters:
number1: 10
number2: 20
Task2:
type: blah
# repeats like Task1 above
QA:
taskOrder:
- TaskA
- TaskB
tasks:
TaskA:
type: ssh
ignoreFailure: false
preCondition: ''
input:
host: x.y.z.w
username: abcd
password: ${var.mypassword}
script: >
echo "Hello, remote server"
TaskB:
type: blah
# repeats like TaskA above
# Notificatons Section
notifications:
email:
- stage: Dev #optional ; if not found - use pipeline scope
task: Task1 #optional; if not found use stage scope
event: SUCCESS
endpoint: default
to:
- user@yourcompany.com
- abc@yourcompany.com
subject: 'Pipeline ${name} has completed successfully'
body: 'Pipeline ${name} has completed successfully'
jira:
- stage: QA #optional ; if not found - use pipeline scope
task: TaskA #optional; if not found use stage scope
event: FAILURE
endpoint: myJiraServer
issuetype: Bug
project: Test
assignee: abc
summary: 'Pipeline ${name} has failed'
description: |-
Pipeline ${name} has failed
Reason - ${resultsText}
webhook:
- stage: QA #optional ; if not found - use pipeline scope
task: TaskB #optional; if not found use stage scope
event: FAILURE
agent: my-remote-agent
url: 'http://www.abc.com'
headers: #requestHeaders: '{"build_no":"123","header2":"456"}'
Content-Type: application/json
Accept: application/json
payload: |-
Pipeline ${name} has failed
Reason - ${resultsJson}
---
이 YAML 코드는 Jenkins 끝점 예를 나타냅니다.
--- name: My-Jenkins tags: - My-Jenkins - Jenkins kind: ENDPOINT properties: offline: true pollInterval: 15.0 retryWaitSeconds: 60.0 retryCount: 5.0 url: http://urlname.yourcompany.com:8080 description: Jenkins test server type: your.jenkins:JenkinsServer isLocked: false ---
이 YAML 코드는 Kubernetes 끝점 예를 나타냅니다.
--- name: my-k8s tags: [ ] kind: ENDPOINT properties: kubernetesURL: https://urlname.examplelocation.amazonaws.com userName: admin password: encryptedpassword description: '' type: kubernetes:KubernetesServer isLocked: false ---
다음에 수행할 작업
파이프라인을 실행하고 필요에 따라 조정을 수행합니다. 파이프라인을 실행하고 결과를 보는 방법 항목을 참조하십시오.