Jobs

Pipeline configuration begins with jobs:

  • Jobs are the most fundamental element of a pipeline and are executed by GitLab Runners
  • Jobs are created with constraints, which govern under what conditions they should be executed
  • Jobs are top-level elements that can have an arbitrary name and must contain the script element as a minimum requirement
  • There can be an unlimited number of jobs

In the pipeline overview, you'll find several jobs. They have a status, an ID, are part of a stage, and have a name, as shown in the following screenshot:

You can create jobs by adding them to a configuration file called .gitlab-ci.yml. We will discuss this file in more depth in the following section.

An example of a pipeline containing two jobs is as follows:

job1:
script: "execute-this-script-for-job1"
job2:
script: "execute-this-script-for-job2"

The preceding example is a basic CI/CD pipeline that consists of two named jobs (job1 and job2), which execute a script section (in our example, this does nothing). In the script section, you can specify a command, script, or a chain of commands. For instance, to build a JavaScript, you can set script as npm build or run a shell unit test called unit-test.sh.

Jobs are not run on the GitLab application server, but are picked up by GitLab Runners. The runners execute the jobs in their own environment; for example, runner A can build job1 and runner B can build job2. Note that the jobs are independent from each other. The results from these jobs are aggregated on the GitLab server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.165.246