Search code examples
tekton

How to write a tekton result api example call


I'd like to query the results of taskruns from tektoncd result api, but I have a hard time putting the query together. Can you help me, please?

I've completed the steps at https://github.com/tektoncd/results/blob/main/docs/install.md

Not sure how a curl call would look like.


Solution

  • Example API call querying for Tekton-related objects:

    curl -k --header 'Authorization: Bearer xxx' \
      https://api-k8s.xxx.com:6443/apis/tekton.dev/v1beta1/namespaces/YOUR_NAMESPACE_HERE/pipelineruns | jq '.[]'
    curl -k --header 'Authorization: Bearer xxx' \
      https://api-k8s.xxx.com:6443/apis/tekton.dev/v1beta1/namespaces/YOUR_NAMESPACE_HERE/taskruns/YOUR_RESOURCE_NAME_HERE | jq '.[]'
    

    See Kubernetes docs, for guidance building URLs when querying the API

    Knowing of a taskrun name, we can query for its results with the following:

    curl -s -k --header 'Authorization: Bearer xxx' \
       https://api-k8s.xxx.com:6443/apis/tekton.dev/v1beta1/namespaces/ci/taskruns/scalelite-recording-importer-1.3.4-1-build \
       | jq .status.taskResults
    [
      {
        "name": "IMAGE_DIGEST",
        "type": "string",
        "value": "sha256:14e52d648f6e99e4b339272658b2a7d57f81f145b0f3f178a0deccb65300a75c"
      }
    ]