3.5. Bitbucket Data Center에서 Pipeline을 코드로 사용
조직 또는 프로젝트에서 Bitbucket Data Center를 기본 플랫폼으로 사용하는 경우 Bitbucket Data Center에서 Webhook가 있는 리포지토리의 코드로 Pipeline을 사용할 수 있습니다.
사전 요구 사항
- Pipeline as Code가 클러스터에 설치되어 있는지 확인합니다.
Bitbucket Data Center에서 프로젝트 관리자로 개인 액세스 토큰을 생성하여 대체 위치에 저장합니다.
참고-
토큰에는
PROJECT_ADMIN
및REPOSITORY_ADMIN
권한이 있어야 합니다. - 토큰에는 가져오기 요청에서 분기된 리포지토리에 액세스할 수 있어야 합니다.
-
토큰에는
프로세스
OpenShift 클러스터에서 Pipeline의 공용 URL을 코드 컨트롤러로 추출합니다.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow echo https://$(oc get route -n openshift-pipelines pipelines-as-code-controller -o jsonpath='{.spec.host}')
$ echo https://$(oc get route -n openshift-pipelines pipelines-as-code-controller -o jsonpath='{.spec.host}')
Bitbucket Data Center에서 다음 단계를 수행합니다.
- Bitbucket Data Center 리포지토리의 왼쪽 탐색 창을 사용하여 리포지토리 설정 -> Webhook로 이동하고 Webhook 추가 를 클릭합니다.
- 제목 을 설정합니다. 예를 들어 "Pipelines as Code"가 있습니다.
- URL 을 코드 컨트롤러 공용 URL로 Pipeline으로 설정합니다.
웹 후크 시크릿을 추가하고 복사본을 대체 위치에 저장합니다. 로컬 머신에
openssl
을 설치한 경우 다음 명령을 사용하여 임의의 시크릿을 생성합니다.Copy to Clipboard Copied! Toggle word wrap Toggle overflow openssl rand -hex 20
$ openssl rand -hex 20
다음 이벤트를 선택합니다.
- 리포지토리: 푸시
- 리포지토리: Cryostat
- 가져오기 요청: 개설됨
- 가져오기 요청: 소스 분기 업데이트
- 가져오기 요청: 주석 추가
- 저장을 클릭합니다.
OpenShift 클러스터에서 대상 네임스페이스에 app 암호를 사용하여
Secret
오브젝트를 생성합니다.Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc -n target-namespace create secret generic bitbucket-datacenter-webhook-config \ --from-literal provider.token="<PERSONAL_TOKEN>" \ --from-literal webhook.secret="<WEBHOOK_SECRET>"
$ oc -n target-namespace create secret generic bitbucket-datacenter-webhook-config \ --from-literal provider.token="<PERSONAL_TOKEN>" \ --from-literal webhook.secret="<WEBHOOK_SECRET>"
리포지토리
CR을 생성합니다.예:
리포지토리
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow apiVersion: "pipelinesascode.tekton.dev/v1alpha1" kind: Repository metadata: name: my-repo namespace: target-namespace spec: url: "https://bitbucket.com/workspace/repo" git_provider: url: "https://bitbucket.datacenter.api.url/rest" user: "<BITBUCKET_USERNAME>" secret: name: "bitbucket-datacenter-webhook-config" key: "provider.token" # Set this if you have a different key in your secret webhook_secret: name: "bitbucket-datacenter-webhook-config" key: "webhook.secret" # Set this if you have a different key for your secret
apiVersion: "pipelinesascode.tekton.dev/v1alpha1" kind: Repository metadata: name: my-repo namespace: target-namespace spec: url: "https://bitbucket.com/workspace/repo" git_provider: url: "https://bitbucket.datacenter.api.url/rest"
1 user: "<BITBUCKET_USERNAME>"
2 secret:
3 name: "bitbucket-datacenter-webhook-config" key: "provider.token" # Set this if you have a different key in your secret webhook_secret: name: "bitbucket-datacenter-webhook-config" key: "webhook.secret" # Set this if you have a different key for your secret
참고Bitbucket Data Center에서
tkn pac create
및tkn pac bootstrap
명령은 지원되지 않습니다.
추가 리소스
- Bitbucket Data Center에서 개인 토큰 생성 (Atlassian 문서)
- Bitbucket Data Center에서 Webhook 관리 (Atlassian 문서)