title: “Create Buildconfig and trigger from github”
date: 2020-12-11T10:37:15
slug: create-buildconfig-and-trigger-from-github
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
name: sec-git
namespace: sec
selfLink: /apis/build.openshift.io/v1/namespaces/sec/buildconfigs/sec-git
uid: 176a09a4-324a-4208-847a-d5fd4c409a18
resourceVersion: '6483992'
creationTimestamp: '2020-12-11T08:23:22Z'
labels:
app: sec-git
app.kubernetes.io/component: sec-git
app.kubernetes.io/instance: sec-git
app.kubernetes.io/name: php
app.kubernetes.io/part-of: sec
app.openshift.io/runtime: php
app.openshift.io/runtime-version: 7.3-ubi7
annotations:
app.openshift.io/vcs-ref: master
app.openshift.io/vcs-uri: 'https://github.com/xforze/sec.git'
openshift.io/generated-by: OpenShiftWebConsole
managedFields:
- manager: openshift-apiserver
operation: Update
apiVersion: build.openshift.io/v1
time: '2020-12-11T10:10:26Z'
fieldsType: FieldsV1
fieldsV1:
'f:status':
'f:lastVersion': {}
- manager: Mozilla
operation: Update
apiVersion: build.openshift.io/v1
time: '2020-12-11T10:34:43Z'
fieldsType: FieldsV1
fieldsV1:
'f:metadata':
'f:annotations':
.: {}
'f:app.openshift.io/vcs-ref': {}
'f:app.openshift.io/vcs-uri': {}
'f:openshift.io/generated-by': {}
'f:labels':
.: {}
'f:app': {}
'f:app.kubernetes.io/component': {}
'f:app.kubernetes.io/instance': {}
'f:app.kubernetes.io/name': {}
'f:app.kubernetes.io/part-of': {}
'f:app.openshift.io/runtime': {}
'f:app.openshift.io/runtime-version': {}
'f:spec':
'f:output':
'f:to':
.: {}
'f:kind': {}
'f:name': {}
'f:runPolicy': {}
'f:source':
'f:contextDir': {}
'f:git':
.: {}
'f:uri': {}
'f:type': {}
'f:strategy':
'f:sourceStrategy':
.: {}
'f:from':
.: {}
'f:kind': {}
'f:name': {}
'f:namespace': {}
'f:type': {}
'f:triggers': {}
spec:
triggers:
- type: GitHub
github:
secretReference:
name: github
- type: GitHub
github:
secretReference:
name: sec-git-github-webhook-secret
- type: ImageChange
imageChange:
lastTriggeredImageID: >-
image-registry.openshift-image-registry.svc:5000/openshift/php@sha256:4173a6d7361c1d5d1154b0d24580c4abd2954c9116b9f91e79f297689e9fd9f9
- type: ConfigChange
runPolicy: Serial
source:
type: Git
git:
uri: 'https://github.com/xforze/sec.git'
contextDir: /
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
namespace: openshift
name: 'php:7.3-ubi7'
output:
to:
kind: ImageStreamTag
name: 'sec-git:latest'
resources: {}
postCommit: {}
nodeSelector: null
successfulBuildsHistoryLimit: 5
failedBuildsHistoryLimit: 5
Create the github Secret
oc create secret generic github --from-literal=WebHookSecretKey=adfawertwetwer
Get the Webhook Url:
oc describe bc sec
Replace with the Secret Value:
https://api.ocp4-thasanger.paas.pop.noris.de:6443/apis/build.openshift.io/v1/namespaces/sec/buildconfigs/sec-git/webhooks//github
Activate Image Trigger in Deploymentconfig:
oc set triggers dc/sec --auto
