nerdexam
Microsoft

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

Author and Maintain Workflows

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

GH-200 question #57 exhibit 1
GH-200 question #57 exhibit 2
GH-200 question #57 exhibit 3
GH-200 question #57 exhibit 4

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)
  • A
    72% (23)
  • B
    9% (3)
  • C
    16% (5)
  • D
    3% (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

#GitHub Actions#Workflow Definition#Matrix Strategy#Node.js

Community Discussion

No community discussion yet for this question.

Full GH-200 Practice