Triggering Builds On Commits, Merges, And Tags
You can trigger a build when committing, merging, and pushing tags to your project. This is the default behavior. See working with tags for more information on pushing tags.
To trigger a build on commit, builds and tags:
-
Go to Project Settings.
-
Select the Build Triggers tab.
-
Select the Build on commit, merge, and tags radio button.
-
Click the Save Configuration button.
Triggering Builds Only On Pull Requests
You can trigger a build when opening, merging, and updating a Pull Request (PR).
To trigger a build only on PRs:
-
Go to Project Settings.
-
Select the Build Triggers tab.
-
Select the Build only on PR events radio button.
-
Click the Save Configuration button.
Note: The following environment variables are populated after the Build only on PR events configuration is saved: * CI_PR_NUMBER is populated with the pull request number. * CI_PULL_REQUEST is populated with the URL of the pull request.
See CodeShip Basic Environment Variables or CodeShip Pro Environment Variables for more information.
Triggering Builds on Commits versus on Pull Requests
The following table shows when a build is triggered.
Trigger a Build on Commit, Merge, Tags | Trigger A Build On Pull Requests | ||
---|---|---|---|
Push a Commit |
Yes |
No |
|
Push a Tag |
Yes |
No |
|
Open a Pull Request |
No |
Yes |
|
Update a Pull Request |
Yes |
Yes |
|
Merge a Pull Request |
Yes |
Yes |
Configuring Branches
You can run builds for all branches, exclude branches from triggering builds, and run builds only for certain branches. The default behavior is to run builds for all branches.
Excluding Branches From Triggering Builds
To exclude branches from triggering a build:
-
Go to Project Settings.
-
Select the Build Triggers tab.
-
Select the Don’t run builds for these branches radio button.
-
Enter either full branch names like "master" for exact matches or a regular expressions like "^release.*$" for a search pattern.
-
Click the Save Configuration button.
Running Builds Only For These Branches
To run builds only on certain branches:
-
Go to Project Settings.
-
Select the Build Triggers tab.
-
Select the Run build for these branches only radio button.
-
Enter either full branch names like "master" for exact matches or a regular expressions like "^release.*$" for a search pattern.
-
Click the Save Configuration button.
Skipping builds on the same branch
The auto-supersede feature can automatically skip builds in the queue when a newer build on the same branch comes in. By running a build based upon the latest commit, you can streamline the builds and save time. If a code change commit contains an error and a subsequent commit corrects that error, this feature can skip the build with the error and run the fixed, latest build.
The auto-supersede feature adds a new state, skipped, to the build list.
The following example shows how builds are skipped. First, you have a build that is running and another build that is queued.
Next, pushing a commit queues a new build. The queued build appears on the top line of the build list. CloudBees CodeShip Pro, updates the build list in real time, so the status of a build appears as skipped immediately.
CloudBees CodeShip Basic only updates a build status to skipped once the build had completed running. In the following, the build succeeded.
You can not restart a skipped build. You can view the build on your source code management (SCM) system or go to Project Settings by clicking the drop-down arrow,
To automatically skip builds on the same branch:
-
Go to Project Settings.
-
Select the Build Triggers tabs.
-
Select the Auto-supersede radio button to On.
-
Click the Save the Configuration button.