Learner Dotcom
Learner Dotcom

Reputation: 19

How to use dynamic value for start_in using environment variable in GitLab pipeline child job

I need to start child GitLab pipeline job using environment variable. I tried below but getting error as jobs:job2 start in should be a duration.

variables:
  DYNAMIC_START_IN: "1 minute" # Set your dynamic start time here.

job1:
  script:
    - echo "Starting job in $DYNAMIC_START_IN"
  start_in: $DYNAMIC_START_IN

I tried sending in environment variable and was expecting variable value sent to delay child pipeline job. However, getting error as jobs:job2 start in should be a duration

Upvotes: 2

Views: 202

Answers (1)

Miguel Mucio
Miguel Mucio

Reputation: 1

I created a workaround solution: The pipeline which must be scheduled have two extras jobs, both at the same stage. The second one hold the pipeline because it is in manual. The first one check if there's a window deploy active for that project, if so, this first job plays the second one, relesaing the pipeline, if not the first job, schedule a pipeline at desire date/time in an auxiliar repository which has a pipeline just to play the job in hold in the project pipeline. I used gitlab api to create all this workaround solution. If you need to hold the pipeline for nobody plays it out of deploy window, I believe you can use deploy freeze feature available in gitlab to achieve this

Upvotes: 0

Related Questions