lddsb / drone-dingtalk-message

A plugins for drone ci to message a group by robot
MIT License
63 stars 31 forks source link

自定义 `tips_title` 的时候无法获取真正DRONE_BUILD_STATUS的小问题 #44

Open YahuiWong opened 2 years ago

YahuiWong commented 2 years ago

我想要在 tips_title 里面 显示 构建状态的时候尝试使用 ${DRONE_JOB_STATUS} ${DRONE_PREV_BUILD_STATUS} ${DRONE_BUILD_STATUS} ,发布只有 DRONE_BUILD_STATUS 是有值的,而且展示出来的效果永远是 success(实际是failure)

下面是我的代码

-   name: DingTalk
    image: lddsb/drone-dingtalk-message
    settings:
        token: 
          from_secret: dingtalk_token
        secret:
          from_secret: dingtalk_secret
        type: markdown
        tips_title: "${DRONE_REPO} build ${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:8}  No.${DRONE_BUILD_NUMBER} ${DRONE_JOB_STATUS}-${DRONE_PREV_BUILD_STATUS}-${DRONE_BUILD_STATUS}"
    when:
        status: [ success, failure ]
lddsb commented 2 years ago

请问是在GitLab-CI上遇到的问题吗?

YahuiWong commented 2 years ago

请问是在GitLab-CI上遇到的问题吗?

是在gitea上遇到的问题。

lddsb commented 2 years ago

请问是在GitLab-CI上遇到的问题吗?

是在gitea上遇到的问题。

我这几天抽空看下

lddsb commented 2 years ago

爬了一下论坛,Drone作者表示 DRONE_JOB_* 的变量都已经废弃,至于 DRONE_PREV_BUILD_STATUS 我没有在官方文档中找到相关的说明 image

lddsb commented 2 years ago

至于 DRONE_BUILD_STATUS 状态始终为 success 的问题,方便提供一下脱敏后完整的 .drone.yaml 文件吗?

YahuiWong commented 2 years ago

至于 DRONE_BUILD_STATUS 状态始终为 success 的问题,方便提供一下脱敏后完整的 .drone.yaml 文件吗?

kind: pipeline
type: docker
name: default

steps:
-   name: publish2registry-${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:8}
    image: plugins/docker
    volumes:
    - name: dockercache
      path: /drone/docker
    - name: dockersock
      path: /var/run/docker.sock
    settings:
        registry: ***
        repo: *****
        tags: ${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:8}
        username: 
          from_secret: registry_username
        password:
          from_secret: registry_password
        dockerfile: Dockerfile
        pull_image: false
        storage_path: /drone/docker
        use_cache: true
    when:
        event: [push, tag, deployment]
        branch: [dev, staging, master]
-   name: argocd deploy
    image: yahuiwong/drone-argocd-plugin:v2.3.3
    environment:
      ARGOCD_AUTH_TOKEN:
        from_secret: argocd_auth_token 
      ARGOCD_SERVER:
        from_secret: argocd_server
    commands:
      - argocd --insecure app sync ***  --prune
    volumes:
    - name: dockercache
      path: /drone/docker
    - name: dockersock
      path: /var/run/docker.sock
-   name: DingTalk
    image: lddsb/drone-dingtalk-message
    settings:
        token: 
          from_secret: dingtalk_token
        secret:
          from_secret: dingtalk_secret
        type: markdown
        tips_title: "${DRONE_REPO} build ${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:8}  No.${DRONE_BUILD_NUMBER} ${DRONE_JOB_STATUS}-${DRONE_PREV_BUILD_STATUS}-${DRONE_BUILD_STATUS}"
    when:
        status: [ success, failure ]
    volumes:
    - name: dockercache
      path: /drone/docker
    - name: dockersock
      path: /var/run/docker.sock
volumes:
- name: dockercache
  host:
    path: /data/cache/drone.docker
- name: dockersock
  host:
    path: /var/run/docker.sock
YahuiWong commented 2 years ago

https://docs.drone.io/pipeline/environment/reference/drone-build-status/ 看到这个字段的说明 默认是 success

YahuiWong commented 2 years ago

https://github.com/lddsb/drone-dingtalk-message/issues/36 参考 这个issues 的方法 写成两个 不太优雅