Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Schedule a cron job in gitlab by using parameters  (Read 83743 times)

0 Members and 1 Guest are viewing this topic.

Santosh

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Windows 10
    Schedule a cron job in gitlab by using parameters
    « on: July 13, 2021, 07:52:09 AM »
    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

    • Global Moderator


    • Intermediate
    • Thanked: 15
      • Experience: Experienced
      • OS: Linux variant
      Re: Schedule a cron job in gitlab by using parameters
      « Reply #1 on: July 13, 2021, 01:28:39 PM »
      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

        Topic Starter


        Rookie

        • Experience: Beginner
        • OS: Windows 10
        Re: Schedule a cron job in gitlab by using parameters
        « Reply #2 on: July 14, 2021, 06:11:40 AM »
        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

        Code: [Select]
        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

        • Global Moderator


        • Intermediate
        • Thanked: 15
          • Experience: Experienced
          • OS: Linux variant
          Re: Schedule a cron job in gitlab by using parameters
          « Reply #3 on: July 14, 2021, 07:35:37 AM »
          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

            Topic Starter


            Rookie

            • Experience: Beginner
            • OS: Windows 10
            Re: Schedule a cron job in gitlab by using parameters
            « Reply #4 on: July 15, 2021, 10:46:21 PM »
            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

            • Global Moderator


            • Intermediate
            • Thanked: 15
              • Experience: Experienced
              • OS: Linux variant
              Re: Schedule a cron job in gitlab by using parameters
              « Reply #5 on: July 16, 2021, 08:40:07 AM »
              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