#Trigger job manually

17 messages · Page 1 of 1 (latest)

icy lotus
#

I have a pipeline that has many jobs in it. I want to only trigger one job. If I trigger the pipeline it's triggering all jobs. I'm wondering if I can simulate the changes block via variables somehow, or do I need to adjust the rules to allow manual running of a specific job?

plan:s3: extends: .s3-pipeline stage: plan script: - terraform init - terraform plan -out tf.plan artifacts: paths: - s3/ rules: - if: '$CI_COMMIT_BRANCH == "develop" || $CI_PIPELINE_SOURCE == "merge_request_event"' changes: - s3/**/*

#

gonna try jsut adding - when: manual to the rules

#

So my next question is, if I go to run a new pipeline, I still don't have a way to specify just this one job 🤔

#

I presume I would have to add an if and a variable to the - when: manual rule

half forum
#

There are probably a few ways you can do it, depending on how your pipeline is being triggered.

You can certainly use a variable, like you're suggesting - e.g. have some jobs with rules that control whether they run/don't run based on the value of a variable. You can then set that variable e.g. in the web UI when running a pipeline, if that's how you're starting it

icy lotus
#

Yeah, setting variables then requires people to remember/lookup the variable and values, so adding a - when: manual to all jobs as the last rule probably makes the most sense

half forum
#

Well, that's certainly another way, if you want people to be able to pick specific jobs to run. I wouldn't say it's a particularly common workflow though.

icy lotus
#

Either way you have to trigger the pipeline, right?

#

so might as well let them click the play button on the specific job in the corresponding pipeline?

#

keep in mind this is only for a manual run of the pipeline, which is rare here

half forum
#

I think it depends what you're trying to do

#

I'm just saying that it's not typical that people trigger a pipeline, and then have to go to the pipeline and 'play' individual jobs.

I'm not suggesting that it's definitely 'wrong' - but noting that it's not a very common practice IME.

What is it that these jobs do? Just wondering why they need to be manually selected?

icy lotus
#

pipeline's up above, running terraform 🙂

#

The code may not change, but an underlying terraform plan can change if something manual has been done to resources terraform manages, so you might want to run it by hand here or there

#

I think I should say I'm mostly just surprised when you go to start a pipeline in the ui I'm shocked you can't just pick a job by default.

half forum
#

It's just not something that it's really designed for running individual jobs like that on a case-by-case basis I think

#

I'm not really very familiar with Terraform, so I can't really say if there might be a 'better' approach - or rather, one that's more in keeping with GitLab's CI/CD paradigms