Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on How to disable jobs in GitLab CI after they are successfully executed

Post

How to disable jobs in GitLab CI after they are successfully executed

+5
−1

I'm working with GitLab CI. The pipelines I'm designing contain several jobs that, once executed successfully, there shouldn't be any reason to retry/rerun them. This is an example:

default:
  # Cache set up
  image: docker.io/library/eclipse-temurin:21-jdk-alpine

stages:
  - verification
  - testing
  - assembly
  - deployment

# Global environment variables

assess-code-quality:
  ...
  stage: verification

build-release:
  ...
  stage: assembly

deploy-dev:
  ... # manual job
  stage: deployment

deploy-test:
  needs: deploy-dev
  ... # manual job
  stage: deployment

deploy-prod:
  needs: deploy-test
  ... # manual job
  stage: deployment

test-release:
  ...
  stage: testing

verify-source-code-formatting:
  ...
  stage: verification

I've been searching through the CI/CD YAML syntax reference, but I haven't found anything to accomplish this across the board.

To clarify, I want to make sure that jobs like assess-code-quality, build-release, and others do not allow for reruns if they complete successfully within a given pipeline, not across the pipelines.

Any help or examples would be greatly appreciated!

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Retry/rerun when? (4 comments)
Retry/rerun when?
Iizuki‭ wrote 7 days ago

In what situation you find that your jobs are rerun needlessly? I can think of several possibilities: commit, retrying failed pipeline, manually triggered pipeline...

ɯıpɐʌ‭ wrote 7 days ago

This may be different for each team, but in my case, specifically regarding applications and services, each commit represents a significant piece of work and serves as a release candidate. When these commits are finally merged into the main branch, each will be treated as a potential release.

That being said, to optimize this process, I would like to prevent the re-execution of jobs that have already run successfully for any given pipeline because the results are idempotent, meaning that running them again will not produce different outcomes — when constrained to the context of a given pipeline.

So basically I'm focused on preventing the re-execution of jobs that have succeeded; I understand that jobs can fail for various reasons, but re-running a failed job often doesn’t make sense unless the failure was sporadic, such as due to an agent failure.

More importantly, I would like to prevent deployments from previous releases.

Iizuki‭ wrote 5 days ago

Right so you mean following situation?

  1. A commit is pushed to branch A and a pipeline is triggered.
  2. The branch gets merged to main and the pipeline is triggered again.
  3. (optionally) a tag gets pushed to the repository, triggering yet another pipeline.
ɯıpɐʌ‭ wrote 5 days ago

That's correct — those are the workflows. However, the third option is not allowed because it overlaps with the second one.

But the question is more general, and not tied to any workflow in particular. I'm just looking for a built-in option to disable or prevent a specific job from running again after it has successfully completed in the pipeline.