Triggering a Build Run

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

In the DevOps service, you can create your own private code repositories or connect to external code repositories and trigger the build. For more information, see Creating an External Connection.

You can control the trigger action by specifying the modified files in your repository to be included or excluded during the build run. The file based trigger action is applicable only for the Push event.

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.

    1. Open the navigation menu and click Developer Services. Under DevOps, click Projects.
    2. On the DevOps Projects page, select a project.
    3. On the details page of the project, from the left side, click Triggers.
    4. Click Create Trigger.
    5. Enter a name for the trigger, and select an existing source connection:
      • OCI Code Repository
      • GitHub
      • GitLab
      • Bitbucket Cloud
      • Visual Builder Studio
      • Bitbucket Server
      • GitLab Server
    6. If you choose OCI Code Repository, then select a code repository to commit the changes to.
    7. (Optional) For Bitbucket Cloud and Visual Builder Studio, select a connection containing the authentication credentials and the base URL.

      Connection is required for file-based triggers with Push event.

    8. Click Add Action.
    9. Select a build pipeline to trigger.
    10. (Optional) Select an event from the following options to trigger the build run:
      • Push
      • Pull Request Created
      • Pull Request Updated
      • Pull Request Merged
      • Pull Request Reopened
      Note

      Event availability varies based on the type of code repository. For OCI code repository, only the Push event is supported. For Bitbucket Cloud and Bitbucket Server, the Pull Request Reopened event is not supported.
    11. Select Build run conditions.
      For the Push event, you can trigger the build run by specifying the source branch name and the files to be included or excluded in the build run.
      • (Optional) Enter 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.

      • (Optional) Enter files to include for the trigger action. Files are specified using glob patterns.

        For example, src/**/*.txt includes all text files in the "src" folder. For more examples and details, see Glob Patterns.

      • (Optional) Enter files to exclude for the trigger action. Files are specified using glob patterns.

        For example, **.html excludes all HTML files. For more examples and details, see Glob Patterns.

    12. Save the changes.
    13. Click Create to create the trigger.
    14. In the Trigger secret dialog box, 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, GitLab, and Visual Builder Studio. 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.

      To set up webhooks for the various external repositories, see the following links:

    15. Click Close.
  • 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 create a Visual Builder Studio trigger, run the create-vbs-trigger command:

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

    To create a Bitbucket Server trigger, run the create-bitbucket-server-trigger command:

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

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

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

    To get all the commands for trigger:

    oci devops trigger -h
  • To create a trigger, use the CreateTrigger operation.