3.2. Jenkins에서 OpenShift Pipelines로 샘플 파이프라인 마이그레이션
다음 동등한 예제를 사용하여 Jenkins에서 OpenShift Pipelines로 파이프라인을 마이그레이션, 테스트 및 배포할 수 있습니다.
3.2.1. Jenkins 파이프라인 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
빌드, 테스트 및 배포를 위해 Groovy로 작성된 Jenkins 파이프라인을 고려하십시오.
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'make'
}
}
stage('Test'){
steps {
sh 'make check'
junit 'reports/**/*.xml'
}
}
stage('Deploy') {
steps {
sh 'make publish'
}
}
}
}
3.2.2. OpenShift Pipelines 파이프라인 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
이전 Jenkins 파이프라인과 동일한 OpenShift Pipelines에서 파이프라인을 생성하려면 다음 세 가지 작업을 생성합니다.
build 작업 YAML 정의 파일 예
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: myproject-build
spec:
workspaces:
- name: source
steps:
- image: my-ci-image
command: ["make"]
workingDir: $(workspaces.source.path)
test 작업 YAML 정의 파일 예
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: myproject-test
spec:
workspaces:
- name: source
steps:
- image: my-ci-image
command: ["make check"]
workingDir: $(workspaces.source.path)
- image: junit-report-image
script: |
#!/usr/bin/env bash
junit-report reports/**/*.xml
workingDir: $(workspaces.source.path)
deploy task YAML 정의 파일 예
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: myprojectd-deploy
spec:
workspaces:
- name: source
steps:
- image: my-deploy-image
command: ["make deploy"]
workingDir: $(workspaces.source.path)
세 가지 작업을 순차적으로 결합하여 OpenShift Pipelines에서 파이프라인을 구성할 수 있습니다.
예: 빌드, 테스트 및 배포를 위한 OpenShift Pipelines 파이프라인
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: myproject-pipeline
spec:
workspaces:
- name: shared-dir
tasks:
- name: build
taskRef:
name: myproject-build
workspaces:
- name: source
workspace: shared-dir
- name: test
taskRef:
name: myproject-test
workspaces:
- name: source
workspace: shared-dir
- name: deploy
taskRef:
name: myproject-deploy
workspaces:
- name: source
workspace: shared-dir