Triggering builds ONLY via API

Hi everyone. Been using Gitlab for a while, but just getting around to exploring the whole CI aspect. I have a need that hopefully can be easily addressed.

Our project is huge at almost 2GB for a build. I don’t want to trigger a build for every commit - especially since we commit code all day long in short bursts (due to the nature of this project). What I would like to do is only trigger a build via an on-demand script/job, rather than for every commit.

I understand that by putting the “[skip ci]” primitive in the commit message that it will skip the build process, but with the number of commits we do on a daily basis, invariably, someone is going to forget to do that and trigger this huge build process.

I know I can create a build trigger that I can ping via cURL or what not, but how can I work around the “every commit triggers a build” thing more easily than the “[skip ci]” approach?

Thanks in advance for any ideas!

Cheers.

1 Like

I thought I had figured it out, but alas, I hit a brick wall again lol.

I removed the .yml file so it wouldn’t trigger builds for every commit. But when I ping the API via cURL, it just responds with “{“message”:“No builds created”}”. :frowning:

I must be missing something lol.

You must have a .gitlab-ci.yml in order to perform a build. How else would the Runner know what to run?

What you want is to pass a variable to a trigger and run the script with an if clause. I guess it should work.

Another option is to use only and except in your jobs, so that you could allow the builds to run only on tags.

Makes sense! Thanks for the guidance. I’ll give it a go and see how I fare :smile:

Cheers.

At present you can add this in all the jobs of your .gitlab-ci.yml:

myjob:
    only:
      - triggers

See http://doc.gitlab.com/ce/ci/yaml/README.html#only-and-except
May be this was not existing when this thread was created.