Skip to content

Adds previousStageJobAndNeeds field to JobType

Laura Montemayor requested to merge lm-show-jobs-without-needs-in-order into master

What does this MR do and why?

Query:
{
  project(fullPath: "root/possession") {
    pipeline(iid: "9") {
      jobs {
        nodes {
          name
          needs {
            nodes {
              name
            }
          }
          needsAndPreviousStageJobs {
            nodes{
              name
            }
          }
        }
      }
    }
  }
}
Response:
{
  "data": {
    "project": {
      "pipeline": {
        "jobs": {
          "nodes": [
            {
              "name": "deploy-job",
              "needs": {
                "nodes": [
                  {
                    "name": "lint-test-job"
                  }
                ]
              },
              "previousStageJobsAndNeeds": {
                "nodes": [
                  {
                    "name": "unit-test-job"
                  },
                  {
                    "name": "lint-test-job"
                  }
                ]
              }
            },
            {
              "name": "lint-test-job",
              "needs": {
                "nodes": []
              },
              "previousStageJobsAndNeeds": {
                "nodes": [
                  {
                    "name": "build-job"
                  }
                ]
              }
            },
            {
              "name": "unit-test-job",
              "needs": {
                "nodes": [
                  {
                    "name": "build-job"
                  }
                ]
              },
              "previousStageJobsAndNeeds": {
                "nodes": [
                  {
                    "name": "build-job"
                  }
                ]
              }
            },
            {
              "name": "build-job",
              "needs": {
                "nodes": []
              },
              "previousStageJobsAndNeeds": {
                "nodes": []
              }
            }
          ]
        }
      }
    }
  }
}
gitlab-ci.yml
stages: 
  - build
  - test
  - deploy

build-job:
  stage: build
  script:
    - echo "Compiling the code..."
    - echo "Compile complete."

unit-test-job:
  stage: test
  script:
    - echo "Running unit tests... This will take about 60 seconds."
    - sleep 60
    - echo "Code coverage is 90%"
  needs:
    - build-job

lint-test-job:
  stage: test
  script:
    - echo "Linting code... This will take about 10 seconds."
    - sleep 10
    - echo "No lint issues found."

deploy-job:
  stage: deploy
  script:
    - echo "Deploying application..."
    - echo "Application successfully deployed."
  needs:
    - lint-test-job

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Laura Montemayor

Merge request reports