Query Results Using OPC CLI
Query Results Using OPC CLI
Setting Route
These instructions assume we already created some Pipelineruns in our namespace. It’s also assumed that auth_disable
is set to true in TektonResult
CR..
export NAMESPACE=results-testing
First, let’s get the route location:
RESULTS_API=$(oc get route tekton-results-api-service -n openshift-pipelines --no-headers -o custom-columns=":spec.host"):443
If self-signed certificate was used during results installation, then pass --insecure
flags to opc results
commands.
Getting Results List
Next, we can get the list of results stored which contains the Pipelinruns data with the below commands:
opc results list --insecure --addr ${RESULTS_API} ${NAMESPACE}
We will receive output similar to below.
Name Start Update
results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed 2023-06-29 02:49:53 +0530 IST 2023-06-29 02:50:05 +0530 IST
results-testing/results/ad7eb937-90cc-4510-8380-defe51ad793f 2023-06-29 02:49:38 +0530 IST 2023-06-29 02:50:06 +0530 IST
results-testing/results/d064ce6e-d851-4b4e-8db4-7605a23671e4 2023-06-29 02:49:45 +0530 IST 2023-06-29 02:49:56 +0530 IST
The format of the result’s Name
field is {NAMESPACE}/results/{Pipelinerun UUID}.
Getting Records List
Now, we can list records associated with results which will have logs, Taskruns, and Pipelineruns.
opc results records list --insecure --addr ${RESULTS_API} results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed
# Below is the sample output from above command:
Name Type Start Update
results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed/records/e9c736db-5665-441f-922f-7c1d65c9d621 tekton.dev/v1beta1.TaskRun 2023-06-29 02:49:53 +0530 IST 2023-06-29 02:49:57 +0530 IST
results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed/records/5de23a76-a12b-3a72-8a6a-4f15a3110a3e results.tekton.dev/v1alpha2.Log 2023-06-29 02:49:57 +0530 IST 2023-06-29 02:49:57 +0530 IST
results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed/records/57ce92f9-9bf8-3a0a-aefb-dc20c3e2862d results.tekton.dev/v1alpha2.Log 2023-06-29 02:50:05 +0530 IST 2023-06-29 02:50:05 +0530 IST
results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed/records/e9a0c21a-f826-42ab-a9d7-a03bcefed4fd tekton.dev/v1beta1.TaskRun 2023-06-29 02:49:57 +0530 IST 2023-06-29 02:50:05 +0530 IST
results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed/records/04e2fbf2-8653-405f-bc42-a262bcf02bed tekton.dev/v1beta1.PipelineRun 2023-06-29 02:49:53 +0530 IST 2023-06-29 02:50:05 +0530 IST
results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed/records/e6eea2f9-ec80-388c-9982-74a018a548e4 results.tekton.dev/v1alpha2.Log 2023-06-29 02:50:05 +0530 IST 2023-06-29 02:50:05 +0530 IST
The format of the record’s Name
field is {NAMESPACE}/results/{Run UUID}/records/{Run UUID}.
Fetching Runs YAML
We can get Yaml for Pipelinerun using the below command:
opc results records get --insecure --addr ${RESULTS_API} results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed/records/04e2fbf2-8653-405f-bc42-a262bcf02bed | yq -r .data.value | base64 -d | yq -P '.'
Fetching Logs
Similarly, we can get the logs of Pipelinerun by changing "records" to "logs" in the name of the record associated with PipelineRun:
opc results logs get --insecure --addr ${RESULTS_API} results-testing/results/04e2fbf2-8653-405f-bc42-a262bcf02bed/logs/04e2fbf2-8653-405f-bc42-a262bcf02bed | yq -r .data | base64 -d