Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created July 1, 2021 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chmouel/272df2cfbeef5606ca36d29a9a2d2f96 to your computer and use it in GitHub Desktop.
Save chmouel/272df2cfbeef5606ca36d29a9a2d2f96 to your computer and use it in GitHub Desktop.

How to install Pipelines as Code

Install release.yaml

kubectl apply -f https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/release-0.1/release-0.1.yaml

OpenShift

Expose the EventListenner

oc expose service el-pipelines-as-code-interceptor -n pipelines-as-code

Expose the EventListener as TLS

You need the jq tool for this

oc apply -n pipelines-as-code -f <(oc get -n pipelines-as-code route el-pipelines-as-code-interceptor  -o json |jq -r '.spec |= . + {tls: {"insecureEdgeTerminationPolicy": "Redirect", "termination": "edge"}}')

Get the EventListenner URL and store it somewhere as $EL_URL_ROUTE we will need for Github APP for the Callback URL field.

echo https://$(oc get route -n pipelines-as-code el-pipelines-as-code-interceptor -o jsonpath='{.spec.host}')

Generate a webhook secret and store it somewhere as $WEBHOOK_SECRET

openssl rand -hex 20

Create a Github Application

Create the github app secret in pipelines-as-code

  • Take note of the App ID” at the top and store it somewhere as $APP_ID
  • Scroll down and click on Generate Private key, it will download a file to your computer, take note of the name of the file.
  • On the command line do :
kubectl -n pipelines-as-code create secret generic github-app-secret \
     --from-literal private.key="$(cat ~/Downloads/*.private-.pem)"
     --from-literal application_id="${APP_ID}" \
     --from-literal webhook.secret="$WEBHOOK_SECRET

Create a repository called demo

Add a repository to your app

Get to https://github.com/settings/apps/ and grab the APP URL, here :

Go to Install APP and install the app on the repository

Checkout the repo locally

git clone git@github.com:chmouel/demo.git      

Generate a pipeline

tkn pac repo new

Commit and push it

git checkout -b tektonci
git add .tekton
git commit -m "Add tekton ci 🐱"
git push -u origin tektonci

Watch it working

Inspect the pipelinerun created in the pipelinerun namespace

tkn pr ls -n pipelines-as-code

Get logs of eventlistenner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment