- Make sure gosmee client installed on psi cluster
- 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
)
gh repo create
? 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 praveen4g0/openshift-demo-test on GitHub
? Clone the remote project directory "praveen4g0/openshift-demo-test"? Yes
Cloning into 'openshift-demo-test'...
remote: Enumerating objects: 4, done.
- Run
cd openshift-demo-test/
andgit remote -v
andcat .git/config
tkn pac bootstrap --route-url=https://smee.io/1bwpqwUgaMkPYbRZ
% 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
-
Go to https://github.com/apps/pipelines-as-code-gitops and click Configure and add
openshift-demo-test
to the APP -
git checkout -b demo-openshift-pipeline
-
go mod init github.com/praveen4g0/openshift-demo-test
-
touch main.go
-
vi main.go
-
Insert this
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
fmt.Println(rand.Int())
}
-
Try running below command for linr errors:
golangci-lint run --disable-all -E revive -E errcheck -E nilerr -E gosec
-
vi .tekton
-
mkdir .tekton/tasks/
-
touch .tekton/tasks/slack-notification.yaml
-
Insert this code from https://gist.github.com/praveen4g0/2a492da8d1e65e9346d8bbb547e829c8#file-send-slack-notification-yaml
-
add :
pipelinesascode.tekton.dev/task: "[git-clone, golangci-lint, .tekton/tasks/slack-notification.yaml]"
- or:
pipelinesascode.tekton.dev/task: "[git-clone, golangci-lint, https://rb.gy/ait8sn]"
- add :
# Customize this task if you like, or just do a taskRef
# to one of the hub task.
- name: run-lint
taskRef:
name: golangci-lint
runAfter:
- fetch-repository
workspaces:
- name: source
workspace: source
params:
- name: package
value: github.com/praveen4g0/openshfit-demo-test
- name: flags
value: --disable-all -E revive -E errcheck -E nilerr -E gosec
---
# pipelineSpec:
finally:
- name: finally
taskRef:
name: send-slack-notification
params:
- name: report_success
value: 'true'
- name: log_url
value: "https://console-openshift-console.apps.gitops410-01.ocp-gitops-qe.com"
- name: openshift
value: "true"
-
git add .
-
git commit -m "Added .tektonci & go app"
-
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
-
oc get repo -n demo-openshift-pipeline -o json|jq .items[].pipelinerun_status
-
Click on the pull request link logs to see the logs
-
Show via CLI
tkn pr ls -n demo-openshift-pipeline
-
Adjust
main.go
:
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
fmt.Println(rand.Int()) //nolint:gosec
}
-
Commit
git commit -a -m "Linters"
-
Repush with
git push origin demo-openshift-pipeline
-
Explains auto secret
-
Explains ACL
-
Show
/retest