Maven / GitLab CI Basics Interview Questions
How does parallel job execution work in GitLab CI/CD?
GitLab CI supports running multiple instances of the same job in parallel using the parallel keyword. This is useful for splitting test suites across multiple runners to reduce total execution time.
# Run the same job N times in parallel test: stage: test image: ruby:3.2 script: - bundle exec rspec parallel: 5 # GitLab creates 5 jobs: test 1/5, test 2/5, ..., test 5/5 # Each job gets: CI_NODE_INDEX (1-5) and CI_NODE_TOTAL (5) # Your test framework uses these to split the test suite # Parallel matrix - run job with different variable combinations build: stage: build script: - echo "Node: $NODE_VERSION on $OS" parallel: matrix: - NODE_VERSION: ["18", "20", "22"] OS: ["ubuntu", "alpine"] # Creates 6 jobs: all combinations of NODE_VERSION x OS # Access which shard you are in: test-shard: script: - echo "Running shard $CI_NODE_INDEX of $CI_NODE_TOTAL" - run-tests --split $CI_NODE_TOTAL --shard $CI_NODE_INDEX
| Variable | Value |
|---|---|
| $CI_NODE_INDEX | The index of this parallel job (1-based) |
| $CI_NODE_TOTAL | Total number of parallel jobs |
| $MATRIX_VAR | Matrix variables become env vars in each job |
Parallel jobs all run in the same stage - they start at the same time (assuming runners are available) and the stage completes when all parallel jobs finish. All jobs must pass for the stage to pass.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
