Environment variable with pull request number


#1

Current when a build is triggered by a PR, Buddy set the environment variable BUDDY_EXECUTION_PULL_REQUEST_ID to pull/<PR number>. It’s quite confusing as the name of the variable suggest it contains just the PR number.
It would probably make more sense to set its value to 15 rather pull/15.


#2

Hi Pierre,
Could you send some screenshots? We must be 100% sure that we mean the same.
Thanks.


#3

It’s about the content of the BUDDY_EXECUTION_PULL_REQUEST_ID environment variable.
For example in the build https://app.buddy.works/pierredenisvanduynslager/playground/pipelines/pipeline/150986/execution/5ba1330163115e522d4eaf72 which was triggered by a Pull Request, BUDDY_EXECUTION_PULL_REQUEST_ID is set to pull/23. It would make more sense to set it to 23.
My pipeline just run the command env to display all the environment variables.

I’m not sure which screenshot you would like. You can see the value of BUDDY_EXECUTION_PULL_REQUEST_ID in the logs: https://app.buddy.works/pierredenisvanduynslager/playground/pipelines/pipeline/150986/execution/5ba1330163115e522d4eaf72/action/249935/logs


#4

We have the same question. We are trying to use this to tag Docker images in our repo with the Pull request number and are getting pull/18 when we would expect just the integer value of 18. Is there a different environment variable that we should use to get the integer of the pull request? If not, we will have to write some sort of regex extraction to work around this unfortunately.

Is there an update as to whether this is a bug or intended and if it’s going to get fixed?

Thanks.


#5

Thanks for the response guys, let me consult with the team if there’s a solution to that. Stay tuned.


#6

The task for that is currently in the backlog. For now you can work around it by adding a settable variable to the pipeline (for example PR_ID) + adding the Local Shell action in which you can assign the cut value from BUDDY_EXECUTION_PULL_REQUEST_ID to that variable.

Hope that’s clear!