GH-200 · Question #57
As a DevOps engineer, you are developing workflows to build an application. You have a requirement to create the build targeting multiple node versions. Which code block should you use to define the w
The correct answer is A. jobs: build-app: strategy: matrix: node-ver: [10, 12, 14] steps: - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-ver }}. GitHub Actions matrix strategy syntax requires the strategy keyword at the job level, with matrix nested inside it. The matrix context variables are then referenced using matrix.<variable-name> (e.g., matrix.node-ver). Option B incorrectly uses matrix-strategy as a top-level key
Question
As a DevOps engineer, you are developing workflows to build an application. You have a requirement to create the build targeting multiple node versions. Which code block should you use to define the workflow? A. B. C. D.
Exhibits
Options
- Ajobs: build-app: strategy: matrix: node-ver: [10, 12, 14] steps: - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-ver }}
- Bjobs: build-app: matrix-strategy: node-ver: [10, 12, 14] steps: - uses: actions/setup-node@v3 with: node-version: ${{ matrix-strategy.node-ver }}
- Cjobs: build-app: matrix: strategy: node-ver: [10, 12, 14] steps: - uses: actions/setup-node@v3 with: node-version: ${{ matrix-strategy.node-ver }}
- Djobs: build-app: strategy: matrix: node-ver: [10, 12, 14] steps: - uses: actions/setup-node@v3 with: node-version: ${{ strategy.node-ver }}
How the community answered
(32 responses)- A72% (23)
- B9% (3)
- C16% (5)
- D3% (1)
Explanation
GitHub Actions matrix strategy syntax requires the strategy keyword at the job level, with matrix nested inside it. The matrix context variables are then referenced using matrix.<variable-name> (e.g., matrix.node-ver). Option B incorrectly uses matrix-strategy as a top-level key and wrong context reference. Option C reverses the nesting order (puts matrix above strategy). Option D uses strategy.node-ver instead of matrix.node-ver as the context reference. Only Option A uses the correct strategy.matrix nesting and matrix.node-ver context syntax.
Topics
Community Discussion
No community discussion yet for this question.



