API for bitrise trigger check

Description of the feature request

I’d like to resolve workflow ids given a branch name.

Use case / for what or how I would use it

Currently the API doesn’t support resolving the pull request trigger map given only a branch. The CLI supports this feature. It’d be nice to have an API and get the workflow ID given pr-target-branch and/or pr-source-branch.

$ bitrise trigger-check --config bitrise.yml --pr-target-branch master
pr-target-branch: master -> debug

Great idea @bootstraponline, thanks for the #feature-request!

If you have some time, can you please share a bit more information about the use case? For what / where would it be used (for what do you need to resolve the workflow id before triggering the build, most likely via some custom integration?)

I want to trigger builds using the default workflow to populate the cache. I am clearing the caches automatically via the API. However the API doesn’t support discovering the default workflow.

val sourceBranch: JsonNode? = map.findValue("pull_request_source_branch")

            if (sourceBranch != null && sourceBranch.asText() == "*") {
                val workflow = map.findValue("workflow").asText()
                println("Triggering build for ${app.title} using workflow $workflow")

                val buildParams = BuildParams(workflow_id = workflow)
                val build = BitriseApps.triggerBuild(app.slug, BitriseTriggerBuildRequest(build_params = buildParams))
                println("  ${build.build_url}")
                triggered = true
                break
            }
1 Like

Do you have Trigger Map for the default workflow? I guess you do otherwise it wouldn’t be the “default” :thinking:
If you do then you can trigger a build with just a “branch=master” parameter, without specifying the workflow - the Trigger Map should select the default workflow for it (if you don’t specify any workflow in the build trigger api call then the Trigger Map will be used to select the right workflow).

  • I have no push triggers
  • We only use pull request triggers
  • I want to run branch=master but it’s not possible, the API rejects this request. There’s no way to tell the API to use the pull request trigger map to start a push job. Pull request builds don’t populate the cache.

I talked in detail about this with Tamas Papik.

I think that’s just the default configuration, it should be possible to change the run_if of the Cache:Push step to make it run in PR builds as well :thinking:

I want the steps to work out of the box though, without requiring code changes. :slight_smile:

Also the goal is to only populate the cache from pushes (and not PRs).

Got it - thanks for the infos! :wink: