Triggering a Build Run

In OCI DevOps, a build run can be automatically triggered when you commit your changes to a code repository.

Before creating a trigger in DevOps, you must have a DevOps project, a build pipeline, and a code repository associated with the project.

To run a build manually, see Running a Build.

For accessing DevOps using the Oracle Cloud Console, REST API, and CLI, see Accessing DevOps.

Using the Console

  1. Open the navigation menu and click Developer Services. Under DevOps, click Projects.
  2. Select a project and click Triggers on the left-side menu.
  3. Click Create Trigger.
  4. Enter a name for the trigger, and select an existing source connection:
    • OCI Code Repository
    • GitHub
    • GitLab
    • Bitbucket Cloud

    DevOps supports connections to GitHub, GitLab, and Bitbucket Cloud external repositories. See Creating an External Connection.

  5. If you choose OCI Code Repository, then select a code repository to commit the changes to.
  6. Click Add Action.
  7. Select a build pipeline to trigger for the commit operation.
  8. (Optional) Select an event that triggers the build run:
    • Push
    • Pull Request Created
    • Pull Request Updated
    • Pull Request Merged
    • Pull Request Reopened

    Event availability varies based on the type of code repository. For OCI code repository, only the Push event is supported. For Bitbucket Cloud, the Pull Request Reopened event is not supported.
  9. Select the source repository branch on which the selected event triggers the build run.
    If you select one of the Pull Request events, then you can also select the target code repository branch.
  10. Save the changes.
  11. Click Create to create the trigger.
  12. Copy the trigger URL and trigger secret because you can't retrieve them again in the Console.

    The trigger secret is applicable only for GitHub and GitLab repositories. For Bitbucket Cloud, the secret is included in the trigger URL. To access the DevOps service from these repositories, you must set up a webhook and secret in the external code repositories.

    For GitHub, see Creating Webhooks, for GitLab, see Webhooks and for Bitbucket Cloud, see Manage webhooks.

Using the CLI

To create an OCI code repository trigger, run the create-devops-code-repo-trigger command:

oci devops trigger create-devops-code-repo-trigger --actions, --project-id

To create a GitHub trigger, run the create-github-trigger command:

oci devops trigger create-github-trigger --actions, --project-id

To create a GitLab trigger, run the create-gitlab-trigger command:

oci devops trigger create-gitlab-trigger --actions, --project-id

To create a Bitbucket Cloud trigger, run the create-bitbucket-cloud-trigger command:

oci devops trigger create-bitbucket-cloud-trigger --actions, --project-id

To get all the commands for trigger:

oci devops trigger -h

Using the API

To create a trigger, use the CreateTrigger operation.