Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipelinerun-with-when-expressions #8163

Open
ForcemCS opened this issue Jul 30, 2024 · 2 comments
Open

pipelinerun-with-when-expressions #8163

ForcemCS opened this issue Jul 30, 2024 · 2 comments

Comments

@ForcemCS
Copy link

I don't understand why my finally task isn't executing:

root@master01:~/v1.30/12-tekton/clone-build-helm# kubectl get   pods  
NAME                                             READY   STATUS      RESTARTS       AGE
clone-build-helm-fqwfv-build-push-pod            0/2     Completed   0              4m14s
clone-build-helm-fqwfv-fetch-source-pod          0/1     Completed   0              4m24s
clone-build-helm-fqwfv-helm-install-middle-pod   0/1     Completed   0              42s

root@master01:~/v1.30/12-tekton/clone-build-helm# cat   01-pipeline.yaml 
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: clone-build-helm
spec:
  description: |
    This pipeline clones a git repo, builds a Docker image with Kaniko and
    pushes it to a registry    
  params:
  - name: repo-url
    type: string
    description: GitLab的项目地址
  - name: subdirectory
    type: string
  - name: gitrevision-tag
    type: string
    description: 项目分支名称
   ....
  finally:
  - name: send-wechat-notification  # when expression using execution status, evaluates to false		  
    when:
      - input: "$(tasks.status)"
        operator: in
        values: ["Completed"]
    taskSpec:
      steps:
        - name: send-notification
          image: curlimages/curl
          script: |
            #!/usr/bin/env sh
              curl 'https://qyapi.weixin.qq.com/xxxxxxxxxxxx' \
                                 -H 'Content-Type: application/json' \
                                 -d '
                                  {
                                      "msgtype": "text",
                                      "text": {
                                          "content": "中台前端发布完成",
                                                  "mentioned_list":["WuKui","@all"]
                                      }
                                  }'

@l-qing
Copy link
Contributor

l-qing commented Aug 2, 2024

To see why the when check was skipped, you should be able to find it in the status of your PipelineRun's YAML.

@l-qing
Copy link
Contributor

l-qing commented Aug 2, 2024

Suggestion:

      when:
        - input: $(tasks.status)
          operator: in
          values: ["Succeeded", "Completed"]

Ref: https://tekton.dev/docs/pipelines/pipelines/#using-aggregate-execution-status-of-all-tasks

Status Description
Succeeded all tasks have succeeded
Failed one ore more tasks failed
Completed all tasks completed successfully including one or more skipped tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants