Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created September 21, 2021 13:08
Show Gist options
  • Save chmouel/0f211fcb533ef3cb2376f1b28736f1ec to your computer and use it in GitHub Desktop.
Save chmouel/0f211fcb533ef3cb2376f1b28736f1ec to your computer and use it in GitHub Desktop.

Prep

  • Make sure tkn-pac is compiled from main
  • Make sure we are on the right cluster ($ opac)
  • Create a demo directory in /tmp (mkdir /tmp/demo)

Use GH to create a repository

  • gh repo create openshfit-demo-test
? Visibility Public
? Would you like to add a .gitignore? Yes
? Choose a .gitignore template Python
? Would you like to add a license? Yes
? Choose a license Apache License 2.0
? This will create the "openshift-demo-test" repository on GitHub. Continue? Yes
✓ Created repository chmouel/openshift-demo-test on GitHub
? Clone the remote project directory "chmouel/openshift-demo-test"? Yes
Cloning into 'openshift-demo-test'...
remote: Enumerating objects: 4, done.
  • Run cat .git/config and github-to-remote-ssh origin and cat .git/config

  • tkn pac repo create

% tkn-pac repository create
? Enter the namespace where the pipeline should run (default: pipelines-as-code):  openshift-demo-test
? Enter the Git repository url containing the pipelines (default: https://github.com/chmouel/openshift-demo-test):
? Enter the target GIT branch (default: main):
? Enter the Git event type for triggering the pipeline:  pull_request
! Namespace openshift-demo-test is not created yet
? Would you like me to create the namespace openshift-demo-test? Yes
✓ Repository openshift-demo-test-pull-request has been created in openshift-demo-test namespace
? Would you like me to create a basic PipelineRun file into the file .tekton/pull_request.yaml ? True
#!/usr/bin/env python3

var = "hello"

if not "hello" in var:
    print("hello var is not")
  • vi .tekton

  • add :

pipelinesascode.tekton.dev/task: "[git-clone, pylint]"

  • add :
    - name: pylint
        runAfter: [fetch-repository]
        params:
          - name: path
            value: "lib/"
          - name: args
            value: ["-r", "y"]
        taskRef:
          name: pylint
        workspaces:
          - name: source
            workspace: source
  • git push origin demo-openshift-pipeline and create a pull request by clicking onto the link

  • See it fails

  • tkn pac repo ls -n demo-openshift-pipeline

  • tkn pac repo describe -n demo-openshift-pipeline

  • Click on the pull request link logs to see the logs

  • Show via CLI tkn pr ls -n demo-openshift-pipeline

  • Adjust app.py :

#!/usr/bin/env python3
"""This is an APP"""

VAR = "hello"

if "hello" not in VAR:
    print("hello var is not")
  • Commit git commit -a -m "Linters"

  • Repush with git push origin demo-openshift-pipeline

  • Explains auto secret

  • Explains ACL

  • Show /retest

  • Show how a push pipeline would look like

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