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

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

Open
YahuiWong opened this issue May 4, 2022 · 8 comments

Comments

@YahuiWong
Copy link

我想要在 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
Copy link
Owner

lddsb commented May 7, 2022

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

@YahuiWong
Copy link
Author

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

是在gitea上遇到的问题。

@lddsb
Copy link
Owner

lddsb commented May 7, 2022

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

是在gitea上遇到的问题。

我这几天抽空看下

@lddsb
Copy link
Owner

lddsb commented May 9, 2022

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

@lddsb
Copy link
Owner

lddsb commented May 9, 2022

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

@YahuiWong
Copy link
Author

至于 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
Copy link
Author

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

@YahuiWong
Copy link
Author

#36 参考 这个issues 的方法 写成两个 不太优雅

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