Schedule a cron job in gitlab by using parameters

Started by Santosh, July 13, 2021, 07:52:09 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Santosh

Schedule a cron job in Gitlab by using parameters as trigger nightly builds

For example:
I have option in Gitlab called schedule and by using that I can schedule a job, but it just triggers a pipeline for that project with default values.

I am configuring it in such a way that my project should trigger on nightly build by using the values provided as a parameter.
Example: for a particular branch the project should trigger and that branch details should come from a YAML file.

So please help me with that.

nil

you should be able to configure and schedule different builds with yaml variables and conditional rules:

https://docs.gitlab.com/ee/ci/pipelines/schedules.html#using-variables

More about the yaml syntax:

https://docs.gitlab.com/ee/ci/yaml/index.html
Do not communicate by sharing memory; instead, share memory by communicating.

--Effective Go

Santosh

I have scheduled a pipeline using cron job. But my requirement is like in the gitlab.yml file we cannot include this below code.
I need to call it from somewhere outside but I am not getting how to call a nightly build for a project without using the main Gitlab project gitlab.yml file

curl --request POST \
  --form token=TOKEN \
  --form ref=main \
  --form "[RUN_NIGHTLY_BUILD]=true" \
  "https://gitlab.example.com/api/v4/projects/9/trigger/pipeline"



nil

It sounds like you are learning Gitlab as a beginner, is that correct? Is this for school?

If you provide some context of what your project is for, I can try to refer you to information that might help.
Do not communicate by sharing memory; instead, share memory by communicating.

--Effective Go

Santosh

I am an employee, but started working on Gitlab from past one year, but this one sounds interesting and this type of builds may use in our projects so I was trying out on my own.

Details of project is, Project has its own pipeline set-up already. But to run it as a scheduled nightly build I am trying out the above curl statement. So please help me on that.

nil

Gotcha. I strongly recommend you post your question directly on the Gitlab forums:

https://forum.gitlab.com/

That's where you'll get the best advice.
Do not communicate by sharing memory; instead, share memory by communicating.

--Effective Go