Make person who triggered a manual build available in an ENV variable

Description of the feature request

The name of the person who triggered a manual build available in an environment variable

Use case / for what or how I would use it

For auditing or otherwise understanding what triggered a build it would be nice to have the name of the user available.

Thanks for the #feature-request @adebree! :slight_smile:

May I ask why you need this information in the build / during the build instead of via e.g. the API? I’d imagine for auditing an API option would be better than an env var during the build :thinking:

Maybe in order to show it on Slack message?

2 Likes

@viktorbenei Exactly wat @bernat says! My primary use case is showing it in slack messages, and secondary use case is to have it available in build logs.

1 Like

@viktorbenei we also wanted access to this for the same reason above.
In our slack message we wanted to mention who triggered a manual build.

So this would be the bitrise account name (or even better the First and Last Name if you have that) of the person who manually triggered the build.

2 Likes

Bumping this. I also have Slack notifications as my primary use case, but this could be generally-useful, as I proposed to @fehersanyi-bitrise:

The feature I’m requesting is simply an environment variable that is present when someone manually triggers a build, which includes information about the Bitrise user that triggered it

This can then be used in workflow scripts, for example: a BITRISE_TRIGGER_SOURCE environment variable that could be “0” for “Webhook”-triggered builds, “1” for “Scheduled”, maybe “3” for manually-launched workflows, etc.

In the manual case, Bitrise could also provide other env vars, e.g. BITRISE_TRIGGER_USER, BITRISE_TRIGGER_EMAIL, etc., which would respectively include the username, email address, etc. of the user who launched the workflow.

Beyond notification routing, this information could also be used as input to build steps that might generate custom artifacts, apps, etc.

I would also like to give a big :+1: for this feature.

2 Likes

Hi
sorry, any update regarding this acclaimed feature?

Hey guys, any update for this feature yet?

+1 though I’d go further and make a Slack app that would allow to invoke Bitrise builds through API, then this info will be available in build parameters or environments (haven’t checked how Bitrise API approaches that but I suppose it would be something like that)

+1 bump. Any updates on this? We would also like the name and email of the person who triggered the Bitrise build exposed to env vars. so we can show it in the slack message like the others previously said.

bump, any news? would be awesome for slack messages

I will see if we can get these values exposed for manually started builds.

For Webhook Triggered builds you can get these values from the Environment Variables

|$GIT_CLONE_COMMIT_AUTHOR_NAME|The name of the author of the cloned commit.|
|$GIT_CLONE_COMMIT_AUTHOR_EMAIL|The email of the author of the cloned commit.|
|$GIT_CLONE_COMMIT_COMMITER_NAME|The name of the committer of the cloned commit.|
|$GIT_CLONE_COMMIT_COMMITER_EMAIL|The email of the committer of the cloned commit.|

See: https://devcenter.bitrise.io/en/references/available-environment-variables.html

Thank you for looking into this :slight_smile: The feature request was idd for the manual trigger.

+1, would find this feature very useful

Here’s a bit of YAML to achieve the same using the Bitrise API in a pipeline. It’s certainly not as easy as an env var would be, but if you need it before an env var is (maybe) made available this can help

- script@1:
        title: Check for manual trigger
        inputs:
        - runner_bin: ruby
        - content: |-
            require "faraday"

            nightly_pl_params = {
                'workflow' => 'nightly',
                'branch' => ENV['BITRISE_GIT_BRANCH']
            }

            auth = {
                'Authorization' => ENV["BITRISE_ACCESS_TOKEN"]
            }

            conn = Faraday.new(
                url: "https://api.bitrise.io/v0.1/apps/#{ENV['BITRISE_APP_SLUG']}/",
                headers: auth
            ) do |f|
                f.request :json
                f.response :json
            end

            # Gets the list of nightly builds for the branch
            nightly_pl_builds = conn.get('builds', params=nightly_pl_params)

            if nightly_pl_builds.body['data'].length > 0
              triggered_by = nightly_pl_builds.body['data'][0]['triggered_by']
              puts "triggered_by: #{triggered_by}" # will be "manual-username" if manually triggered, "schedule" if scheduled etc.

              if triggered_by.start_with?("manual-")
                puts "Manual run detected
              else
                puts "Non-manual trigger detected
              end
            end