Add default environment variable for Pipeline UUID

Issue #13743 resolved
Greg Benkovitz created an issue

Add additional Pipelines default variables. This additional commit context would help with custom notifications, logging, etc. and could be used to determine pipeline workflow path (e.g. is this check-in from the automated merge or from a developer).

BITBUCKET_COMMIT_AUTHOR - Author display name responsible for current commit BITBUCKET_COMMIT_MESSAGE - check-in message associated with current commit. BITBUCKET_PIPELINE_ID - UUID of current pipeline (same id used in addon/pipelines/home#!/results/ link)

Comments (6)

  1. Matt Ryall

    Thanks for the suggestion, Greg.

    This is very similar to an existing issue, #13003. As noted there, you can get the commit information using git commands in your script. For example, the following command will put the commit message of the last commit into an environment variable:

    - BITBUCKET_COMMIT_MESSAGE=`git log -1 --pretty=%B`

    A similar approach will work for the author. Will this work for your use case?

    If it does, I might modify this ticket to just cover the remaining request to have access to the Pipeline UUID. However, I'm a bit unclear on what value the pipeline UUID will provide for you. Can you please explain a bit more how you want to use this in your pipelines build? Thanks!

  2. Greg Benkovitz reporter

    Thanks, Matt! Yes the following lines added to yml do the trick for the first two variables.

            - BITBUCKET_COMMIT_MESSAGE=$(git log -1 --pretty=%B)
            - BITBUCKET_COMMIT_AUTHOR=$(git log -1 --pretty=%an)

    I asked for access to the pipeline UUID in cases where I create custom notifications and still want to include a URL to the specific Bitbucket Pipeline status page (just like what's done with the plain vanilla status messages in Webhooks). Let me know if there's another way to generate this URL within the pipeline logic.

  3. Matt Ryall

    Thanks Greg. Can you give an example of how you're creating custom notifications at the moment? I'm curious how this is working for you today, and what systems you're planning to use this with.

    At the moment, we're focused on a couple of highly voted features and won't be able to fit this change in. But we'll keep it in mind for next time we're looking at environment variable changes. I don't have a good workaround for you right now unfortunately.

  4. Aneita Yang staff

    Hi Greg,

    We now use the build number in the URL for a pipeline, which is available as an environment variable (BITBUCKET_BUILD_NUMBER) for you to use.

  5. Log in to comment