0

Is it possible to ensure that the build preparation is also passed into all subsequent stages and jobs (node environment path + node_modules), without manually running it at the start of each job?

stages:
  - stage: Build
    jobs:
    - job: BuildJob
      steps:
      - task: NodeTool@0
        inputs:
          versionSpec: '24.x'
        displayName: 'Install Node.js'
      - script: npm ci
        displayName: 'Install node modules'
  - stage: Checks
    dependsOn: 
    - Build
    jobs:
    - job: CheckLintJob
      steps:
      - script: npm run lint
        displayName: 'Run linter'
    - job: CheckFormatJob
      steps:
      - script: npm run format:check
        displayName: 'Run prettier check'
    - job: CheckTestJob
      steps:
      - script: npm run test
        displayName: 'Run tests'

Devops stages report

Or do I need to group up the stages and jobs, and just run 5 sequential steps (and lose the modularity)?

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '24.x'
  displayName: 'Install Node.js'

- script: npm ci
  displayName: 'Install node modules'

- script: npm run lint
  displayName: 'Run linter'

- script: npm run format:check
  displayName: 'Run prettier check'

- script: npm run test
  displayName: 'Run tests'

Devops jobs report

0

1 Answer 1

1

Each job creates a new build agent on Azure DevOps pipelines. In your case, you install nodejs on one agent and then run build/test on another. Here, it is better to use one job definition.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the answer, so is there no way to use the "state" of a previous stage and/or job?
Thank you, I was already familiar with output variables, by state I meant the state of the whole project (ensure that the 4 jobs will run on the same device and directory). I will just use 4 steps for now.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.