In a Gitlab pipeline, I have to get the date the pipeline is running, for example, 25 of August. I have to then make two variables, and get the first of that month, and the last of the month. So in this case, it must be variable 1 = August 1st, variable 2 = August 31st, and I need to echo these values when the pipeline is running.
The method I had in mind was:
- Get the date/time the pipeline is running using the inbuilt variable CI_JOB_STARTED_AT .
- Export this value to Python script
- Since CI_JOB_STARTED_AT is always in this format 2021-11-05T20:12:38Z, we can manipulate the data using a slice, and return the the values for the two variables.
- Two variables receive the values and echo the value while the pipeline is running.
What I don't know is if it's the ideal approach or if I can do it using the script in the pipeline. Can someone please tell me how I can approach this problem?
Thanks in advance