woodpecker-ci / woodpecker

Woodpecker is a simple yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
3.89k stars 346 forks source link

CI_PREV_PIPELINE_STATUS is set wrong on workflow failures #3343

Open quotengrote opened 5 months ago

quotengrote commented 5 months ago

Component

other

Describe the bug

I have the following CI-Config:

---
clone:
  git:
    image: woodpeckerci/plugin-git@sha256:7af90de3a9aa5dc93cc0d5cd2e67e28cb237d4b8e891ccacfd9031f78f4b05a8
    settings:
      lfs: false
      partial: false

steps:
  - name: renovate
    image: renovate/renovate:37.174.3@sha256:00979f107926c6a8063acc7b2ae17dd40e67788d4d218fe7c0ea2d59789a22af
    # https://github.com/renovatebot/renovate/discussions/15049
    commands:
      - echo $$DOCKER_HUB_PASSWORD
      - unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
      - renovate
    secrets:
      - source: renovate_token
        target: RENOVATE_TOKEN
      - source: docker_hub_password
        target: DOCKER_HUB_PASSWORD
      - source: github_token  # für Changelogs benötigt
        target: GITHUB_COM_TOKEN
    environment:
      - LOG_LEVEL=debug
    when:
      event:
        exclude:
          - pull_request
          - tag
          - push

and

---
runs_on: [ success, failure ]

depends_on:
  - ci

clone:
  git:
    image: woodpeckerci/plugin-git@sha256:7af90de3a9aa5dc93cc0d5cd2e67e28cb237d4b8e891ccacfd9031f78f4b05a8
    settings:
      lfs: false
      partial: false

steps:
  - name: notify
    image: "registry.mgrote.net/allzweckcontainer:v1.0.158@sha256:5002e660114f09f70812f20a758bf188000f81842918591950a6b43c7d3aa7e5"
    commands:
      - |
        echo "
        Repository: $$CI_REPO_URL
        Ref: $$CI_COMMIT_BRANCH // $$CI_COMMIT_SHA
        Pipeline: $$CI_PREV_PIPELINE_URL // $$CI_PIPELINE_CREATED
        Status: $$CI_PREV_PIPELINE_STATUS
        " | s-nail \
        -s "CI: Renovate - $$CI_PIPELINE_STATUS" \
        -S mta=smtp://docker10.mgrote.net:1025 \
        -S smtp-auth=none \
        -S v15-compat \
        -S from=ci@mgrote.net \
        info@mgrote.net

the last should always run after the first.

But if there is failure in the first file like RC!=0 or i Abort it manually, the variable CI_PREV_PIPELINE_STATUS always contains "success", instead of the expected "failure".

System Info

# https://woodpecker-ci.org/docs/administration/setup
version: '3'

services:
  woodpecker-server:
    restart: always
    container_name: woodpecker-server
    image: "woodpeckerci/woodpecker-server:v2.3.0"
    ports:
      - 8000:8000
    volumes:
      - server-data:/var/lib/woodpecker/
    environment:
      WOODPECKER_OPEN: false
      WOODPECKER_HOST: https://ci.mgrote.net
      WOODPECKER_WEBHOOK_HOST: http://docker10.mgrote.net:8000
      WOODPECKER_GITEA: true
      WOODPECKER_GITEA_URL: https://git.mgrote.net
      WOODPECKER_GITEA_CLIENT: "{{ lookup('keepass', 'woodpecker-oauth2-client-id', 'password') }}"
      WOODPECKER_GITEA_SECRET: "{{ lookup('keepass', 'woodpecker-oauth2-client-secret', 'password') }}"
      WOODPECKER_AGENT_SECRET: "{{ lookup('keepass', 'woodpecker-agent-secret', 'password') }}"
      WOODPECKER_ADMIN: mg
      WOODPECKER_LOG_LEVEL: info
      WOODPECKER_DEBUG_PRETTY: true
    networks:
      - intern
      - traefik
    labels:
      traefik.http.routers.woodpecker.rule: Host(`ci.mgrote.net`)
      traefik.enable: true
      traefik.http.routers.woodpecker.tls: true
      traefik.http.routers.woodpecker.tls.certresolver: resolver_letsencrypt
      traefik.http.routers.woodpecker.entrypoints: entry_https
      traefik.http.services.woodpecker.loadbalancer.server.port: 8000

      traefik.http.routers.woodpecker.middlewares: woodpecker-ipallowlist

      traefik.http.middlewares.woodpecker-ipallowlist.ipallowlist.sourcerange: "192.168.2.0/24,10.25.25.0/24"
      traefik.http.middlewares.woodpecker-ipallowlist.ipallowlist.ipstrategy.depth: 0 # https://doc.traefik.io/traefik/middlewares/http/ipallowlist/#ipstrategydepth

  woodpecker-agent:
    container_name: woodpecker-agent
    image: "woodpeckerci/woodpecker-agent:v2.3.0"
    command: agent
    restart: always
    depends_on:
      - woodpecker-server
    ports:
      - 3032:3000
    volumes:
      - agent-config:/etc/woodpecker
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      WOODPECKER_SERVER: woodpecker-server:9000
      WOODPECKER_AGENT_SECRET: "{{ lookup('keepass', 'woodpecker-agent-secret', 'password') }}"
      WOODPECKER_MAX_WORKFLOWS: 20
      WOODPECKER_DEBUG_PRETTY: true
      WOODPECKER_LOG_LEVEL: info
      WOODPECKER_HEALTHCHECK: true
      WOODPECKER_BACKEND: docker
    networks:
      - intern

volumes:
  server-data:
  agent-config:

# git.mgrote.net -> Settings -> Applications -> woodpecker
# WOODPECKER_GITEA_CLIENT: "{{ lookup('keepass', 'woodpecker-oauth2-client-id', 'password') }}"
# WOODPECKER_GITEA_SECRET: "{{ lookup('keepass', 'woodpecker-oauth2-client-secret', 'password') }}"
# Redirect URL: https://ci.mgrote.net/authorize

######## Networks ########
networks:
  traefik:
    external: true
  intern:
    driver: bridge

Version:

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"2.3.0"}

Additional context

No response

Validations

zc-devs commented 5 months ago

2875, #2197