Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Gitlab – Top 30 GitLab Pipeline Automation FAQ

Here’s a curated set of 30 most frequently asked real-world questions about GitLab CI/CD pipeline automation, with clear and concise answers — perfect for training sessions or real-world use:


✅ Top 30 GitLab Pipeline Automation Questions & Answers


1. What is the difference between needs and dependencies in GitLab CI?

  • needs: Controls execution order (jobs run as soon as dependencies finish), enables parallelism.
  • dependencies: Controls artifact download but doesn’t affect execution order.

2. Can a single job be reused in multiple stages?

  • No, a job can only belong to one stage. You can replicate logic using YAML anchors or templates.

3. How to conditionally run a job only for merge requests?

rules:
  - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
Code language: JavaScript (javascript)

4. How to run jobs only on a specific branch like main or dev?

only:
  - main

Or use:

rules:
  - if: '$CI_COMMIT_BRANCH == "main"'
Code language: JavaScript (javascript)

5. How to cache dependencies between jobs?

cache:
  paths:
    - node_modules/

6. How to share artifacts between jobs?

Use artifacts and dependencies:

job1:
  script: make build
  artifacts:
    paths: [build/]

job2:
  script: deploy
  dependencies: [job1]
Code language: CSS (css)

7. How to trigger another project’s pipeline?

trigger:
  project: my-group/another-project
  branch: main

8. How to create a manual approval job in a pipeline?

when: manual
Code language: HTTP (http)

9. How to run a job only when a tag is pushed?

only:
  - tags

10. Can we define multiple .gitlab-ci.yml files?

  • Yes, use the include: keyword to import local, remote, or project-specific YAML files.

11. How to define environment-specific jobs (dev, staging, prod)?

rules:
  - if: '$CI_ENVIRONMENT_NAME == "staging"'
Code language: JavaScript (javascript)

12. How to use custom variables in GitLab CI?

Define in UI or .gitlab-ci.yml:

variables:
  DEPLOY_ENV: "prod"
Code language: JavaScript (javascript)

13. How to use matrix builds in GitLab?

parallel:
  matrix:
    - VARIANT: [debug, release]
Code language: CSS (css)

14. How to run a job only if certain files changed?

rules:
  - changes:
      - src/**/*
Code language: CSS (css)

15. How to skip pipeline for a commit?

Use [ci skip] in commit message.


16. What is allow_failure: true used for?

It lets a job fail without failing the whole pipeline.


17. How to handle secrets or credentials securely?

Store them as CI/CD variables in GitLab UI (masked and protected if needed).


18. What is the purpose of before_script and after_script?

  • before_script: runs before the main job script.
  • after_script: runs after the main job script (even on failure).

19. How to make a job retry on failure?

retry: 2
Code language: HTTP (http)

20. What is artifacts:expire_in used for?

Sets how long GitLab retains the artifact:

artifacts:
  expire_in: 1 week

21. What is the role of stages in GitLab CI?

Defines the pipeline flow. Jobs in the same stage run in parallel; stages run sequentially.


22. How to conditionally run a job on a variable value?

rules:
  - if: '$DEPLOY_ENV == "prod"'
Code language: JavaScript (javascript)

23. How to disable a job temporarily?

Add:

when: never
Code language: HTTP (http)

24. How to run a job only when another job fails?

when: on_failure
Code language: HTTP (http)

25. How to visualize job dependencies (DAG)?

Use needs: to define dependencies and GitLab will show it in pipeline graph view.


26. Can you trigger child pipelines?

Yes, using:

trigger:
  include: child-pipeline.yml
Code language: CSS (css)

27. How to control concurrency in pipelines?

Use resource_group: to ensure mutual exclusion:

resource_group: deploy-prod
Code language: HTTP (http)

28. How to limit job execution time?

timeout: 15 minutes
Code language: HTTP (http)

29. How to use GitLab CI templates (SAST, DAST, etc.)?

include:
  - template: Security/SAST.gitlab-ci.yml
Code language: PHP (php)

30. How to pass data between jobs?

Use:

  • artifacts (for file data)
  • cache (for shared folders)
  • CI/CD variables (for text/values)

31 To copy artifacts from two separate jobs into a single common directory, you need to follow these steps in GitLab CI/CD:

Combine artifacts from job1 and job2 into a common directory in job3.

stages:
  - build
  - merge

job1:
  stage: build
  script:
    - echo "Job 1 output" > job1.txt
  artifacts:
    paths:
      - job1.txt

job2:
  stage: build
  script:
    - echo "Job 2 output" > job2.txt
  artifacts:
    paths:
      - job2.txt

job3:
  stage: merge
  needs:
    - job: job1
      artifacts: true
    - job: job2
      artifacts: true
  script:
    - mkdir merged
    - cp job1.txt merged/
    - cp job2.txt merged/
    - ls -la merged
  artifacts:
    paths:
      - merged/
Code language: PHP (php)

32 .

To copy artifacts from two jobs into a common directory in GitLab CI, you can use artifacts along with the dependencies or needs keyword to make artifacts available to a third job that merges them.

✅ Goal:

You have:

  • job1 and job2 that create artifacts
  • merge_job that collects them into a shared directory (e.g., merged-artifacts/)

✅ Example .gitlab-ci.yml

stages:
  - build
  - merge

job1:
  stage: build
  script:
    - echo "Job 1 output" > file1.txt
  artifacts:
    paths:
      - file1.txt

job2:
  stage: build
  script:
    - echo "Job 2 output" > file2.txt
  artifacts:
    paths:
      - file2.txt

merge_job:
  stage: merge
  needs: [job1, job2]
  script:
    - mkdir -p merged-artifacts
    - cp job1/file1.txt merged-artifacts/
    - cp job2/file2.txt merged-artifacts/
    - echo "Merged artifacts:"
    - ls -l merged-artifacts
  dependencies:
    - job1
    - job2
  artifacts:
    paths:
      - merged-artifacts/
Code language: PHP (php)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Team Foundation Server 2015 Installation Guide (SQL Express + Update 3)

Install Team Foundation Server 2015 using the original Microsoft download paths, with clear guidance for online, offline, and ISO-based setup. This revised guide also includes an installation workflow, command example, and practical pitfalls to avoid.

Read More

How to Access a Running Docker Container Shell: docker exec vs docker attach

Need a shell inside a running container that is already in detached mode? This updated guide shows the correct workflow, compares docker exec and docker attach, and explains when SSH does and does not make sense.

Read More

Host Your Own NuGet Feed: Local Source vs NuGet.Server vs NuGetGallery

Learn how to host a private NuGet feed using three practical approaches: a local folder source, NuGet.Server, and NuGetGallery. This revised guide includes setup steps, command examples, and a workflow diagram to help you choose the right model.

Read More

Publish NuGet Packages to NuGet.org: CLI Steps, Workflow, and CI Example

Learn how to publish a NuGet package to NuGet.org using either nuget.exe or the dotnet CLI. This revised guide includes a workflow diagram, command comparison, and a CI-friendly example.

Read More

How to Create NuGet Packages with nuget.exe (Assembly, .nuspec, and .csproj Methods)

Learn three practical ways to build NuGet packages using nuget.exe: from an existing assembly, from a convention-based folder layout, or directly from a Visual Studio project. This guide includes commands, folder conventions, token behavior, and common pitfalls.

Read More

Virtualization in DevOps: Using Vagrant, Docker, and Cloud Platforms Together

This guide explains how VM-based workflows, containers, and cloud platforms complement each other in DevOps. It includes a practical workflow, trade-off table, and command examples for day-to-day use.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x