Remote trigger for (re) build CI Gitlab
I am trying to make a remote trigger for (re) build in ci.gitlab. To explain this, I composed this script:
- 2 repositories "lib" and "app1"
- app1 can only be successfully built if lib is included (just solved with .gitlab-ci.yml)
- now i need to call build app1 (master branch only, at best) to commit (or merge request) lib
I tried to figure it out with webhooks, but I couldn't find the url for ci.gitlab.com. Is it possible to do this using the gitlab environment?
source to share
You can do this with the new trigger functions.
In your ci project, find the Triggers section. Add a trigger and use its token like this:
curl -X POST \
-F token=TOKEN \
https://ci.gitlab.com/api/v1/projects/{project_id}/refs/REF_NAME/trigger
( https://about.gitlab.com/2015/08/22/gitlab-7-14-released/ )
Deprecated:
we have the same problem and the way we solve it is clicking and then removing the tag.
This assumes you are running a machine with a Gitlab-CI runner. First, clone the main repository, app1
for you. And in lib
.gitlab-ci.yml
add the steps:
- cd /path/to/app1_repository
- git pull
- git tag ci-trigger master
- git push origin ci-trigger
- git push --delete origin ci-trigger
- git tag -d ci-trigger
Make sure you have the option Tag push events
in your Gitlab settings for Gitlab-CI.
This solution has disadvantages:
- The Gitlab-CI leader must have write permissions to the repository, so it won't work for shared members
- git history will be bloated with all these tags (especially Gitlab UI)
I have opened an issue for this ( https://gitlab.com/gitlab-org/gitlab-ci/issues/223 ) so hopefully they add this functionality to the API ( http://doc.gitlab.com/ci/ api / README.html ).
source to share