Start build after another build passed


#1

Hello,

I’m searching a such solution:
I have development and QA repositories.
I want when build in dev repository passed, should trigger build and of QA repository and start executing tests.

How should do that could help me with any example?

Thanks in advance


#2

The easiest thing to do is create a new GitHub API token with enough privilege, and use it in development repo’s after_success (or similar) to push a commit (or use GitHub API to create a commit) to the QA repo.


#3

I had a similar problem with a main development repository for a library, with multiple repositories for projects that use that library that also need testing (examples, integrations with other programs).

I took a similar approach to what @BanzaiMan mentioned, except I used the Travis API to trigger a build in dependent repositories (using a GitHub bot/machine account with access to the dependent repositories, and its Travis API token).

Using a secret environment variable in Travis to store the API token, I used a script like this to trigger the build in other repositories (the %2F must be used in the url instead of /):

BUILD_MESSAGE="Test ${TRAVIS_REPO_SLUG} ${TRAVIS_COMMIT_RANGE}"
body='{
"request": {
"message":"'
body+="${BUILD_MESSAGE}"
body+='",
"branch":"master"
}}'
curl -s -X POST \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Travis-API-Version: 3" \
    -H "Authorization: token ${TRAVIS_ORG_TOKEN}" \
    -d "$body" \
    https://api.travis-ci.org/repo/GH-ORG%2FGH-REPO/requests

The triggered builds then checkout a copy of the latest code from the development repository. The main downside I’ve noticed is that Travis API requests for triggering builds are limited to 10/hour, so we just run this on commits/PRs to develop.

If you have multiple parallel jobs that all need to pass before triggering a build, you can add a build stage that runs after all of the jobs like this:

- stage: trigger dependent repositories
  if: branch == develop
  before_install: true
  install: true
  script: scripts/trigger-dependent-ci-builds.sh