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

The value of CI_PIPELINE_PARENT is the ID of the parent pipeline #3680

Closed
yitsushi opened this issue May 4, 2024 · 1 comment · Fixed by #3683
Closed

The value of CI_PIPELINE_PARENT is the ID of the parent pipeline #3680

yitsushi opened this issue May 4, 2024 · 1 comment · Fixed by #3683
Labels
bug Something isn't working

Comments

@yitsushi
Copy link

yitsushi commented May 4, 2024

Component

server

Describe the bug

Based on the documentation:

  • CI_PIPELINE_NUMBER: pipeline number
  • CI_PIPELINE_PARENT: number of parent pipeline

My understanding is that the CI_PIPELINE_PARENT should be the CI_PIPELINE_NUMBER of the parent pipeline.

In reality it references to the id of the pipeline and not the actual number.

Expected Behaviour

The CI_PIPELINE_PARENT value is 2 in the deploy pipeline triggered from the pipeline with CI_PIPELINE_NUMBER=2.

Why it's an issue?

In my notifications (Matrix channel for example), I want to see clearly what was the build that was deployed. Now it's a bit messy as I can see:

✅ Build #2 of org/repo succeeded.

and then

✅ Promotion of build #135 to production on org/repo succeeded.

Example

# build.yaml
when:
  event:
    - push

steps:
  - image: alpine
    commands:
      - "echo 'Current: ${CI_PIPELINE_NUMBER}'"
      - "echo 'Parent: ${CI_PIPELINE_PARENT}'"
# deploy.yaml
when:
  environment: production
  event: deployment

steps:
  - image: alpine
    commands:
      - "echo 'Current: ${CI_PIPELINE_NUMBER}'"
      - "echo 'Parent: ${CI_PIPELINE_PARENT}'"
      - "echo 'Target: ${CI_PIPELINE_DEPLOY_TARGET}'"

Output

# build
+ echo 'Current: 2'
Current: 2
+ echo 'Parent: 0'
Parent: 0
# deploy (from the previous pipeline)
+ echo 'Current: 3'
Current: 3
+ echo 'Parent: 139'
Parent: 139
+ echo 'Target: production'
Target: production

I checked in the database and indeed, the build pipeline's ID is 139.

System Info

❯ curl https://cicd.efertone.me/version
{"source":"https://github.com/woodpecker-ci/woodpecker","version":"2.4.1"}

❯ docker stack ps woodpecker
ID             NAME                      IMAGE                                   NODE                         DESIRED STATE   CURRENT STATE           ERROR     PORTS
mszm6rloe7h1   woodpecker_agent.1        woodpeckerci/woodpecker-agent:v2.4.1    xxxxxxxxxxxxxxxxxxxxxxxxxx   Running         Running 5 hours ago
na6d65ec7q9n   woodpecker_agent.2        woodpeckerci/woodpecker-agent:v2.4.1    xxxxxxxxxxxxxxxxxxxxxxxxxx   Running         Running 5 hours ago
ku3ox1z2gt6v   woodpecker_agent.3        woodpeckerci/woodpecker-agent:v2.4.1    xxxxxxxxxxxxxxxxxxxxxxxxxx   Running         Running 5 hours ago
xoszbiy72sn4   woodpecker_server.1       woodpeckerci/woodpecker-server:v2.4.1   xxxxxxxxxxxxxxxxxxxxxxxxxx   Running         Running 11 hours ago
so0d47yoxc5t    \_ woodpecker_server.1   woodpeckerci/woodpecker-server:v2.4.1   xxxxxxxxxxxxxxxxxxxxxxxxxx   Shutdown        Shutdown 11 hours ago
9bwop7cusl6v    \_ woodpecker_server.1   woodpeckerci/woodpecker-server:v2.4.1   xxxxxxxxxxxxxxxxxxxxxxxxxx   Shutdown        Shutdown 12 hours ago


### Additional context

- Demo repo: https://git.efertone.me/efertone/woodpecker-experiment
- Build pipeline: https://cicd.efertone.me/repos/16/pipeline/2
- Deploy pipeline: https://cicd.efertone.me/repos/16/pipeline/3

### Validations

- [X] Read the [docs](https://woodpecker-ci.org/docs/intro).
- [X] Check that there isn't [already an issue](https://github.com/woodpecker-ci/woodpecker/issues) that reports the same bug to avoid creating a duplicate.
- [X] Checked that the bug isn't fixed in the `next` version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
@yitsushi yitsushi added the bug Something isn't working label May 4, 2024
@yitsushi
Copy link
Author

yitsushi commented May 4, 2024

Quick checked if it can be easily fixed with just swapping a value, but sadly the parent's pipeline_number is not saved.

cicd-efertone-me=# select * from pipelines where "pipeline_id" = 140;
-[ RECORD 1 ]--------+-------------------------------------------------------------------------------------------------------
pipeline_id          | 140
pipeline_repo_id     | 16
pipeline_number      | 3
pipeline_author      | efertone
pipeline_parent      | 139

So it seems that data has to be stored as an extra field :( (or query the info every time, I don't know how much stress it would add to a crowded instance, mine is not crowded at all)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant