allow multiple scripts per job

Description

Some jobs need considerable initialization time and could then safely execute multiple scripts.

Currently you can only run one script per job: so when you need to execute 4 scripts, it means that we must run 4 jobs: where each jobs needs to do the full initialization again and executes only one script, which is a waste of build minutes.

Proposal

Allow the definition of multiple scripts per job, e.g.:

build:
  stage: build
  scripts:
    debugBuild:
    - ./gradlew clean assembleDebug
    releaseBuild:
    - ./gradlew clean assembleRelease
    releaseBuildStrictChecks:
    - ./gradlew clean assembleRelease -PstrictChecks

Where

  • scripts is a new keyword for a Job.
  • debugBuild, releaseBuild and releaseBuildStrictChecks are just names of the scripts: which could be shown in the web-page for the build-pipeline and highlighted in the same colors as jobs depending on the script success

Links / references

Related [Issue#36256 "Add the ability to set the build state from within the job (return code)"](https://gitlab.com/gitlab-org/gitlab-ce/issues/36256 https://gitlab.com/gitlab-org/gitlab-ce/issues/36256)
This is related, because we may also need to define how a failed script would affect the job state: e.g. we could define that the job fails when the first script fails, or we could even use some advanced configuration where you can specify for each script what a failure means (e.g. like allow_failure for a Job)

Documentation blurb

Overview

Using artifacts, dependencies and caching can help to reduce the build minutes, but I think this proposal is way more efficient to reduce build minutes.

(e.g. installation of Android-SDK, download of dependencies, etc.)

What is it?
The scripts keyword allows you to execute multiple scripts in a single job.
The goal is to reduce the amount of build minutes that you need.

Why should someone use this feature?
Using this feature can considerably lower the amount of build minutes that you use.

What is the underlying (business) problem?
To reduce the build time because build minutes have a quota for free repositories.

How do you use this feature?
Instead of using multiple Jobs with a single script, you can use one Job with mutiple scripts.

Use cases

Basically it is for all uses who want to reduce build time.

A concrete example use case is a typical Android build.

The initialization step involves downloading and installing the Android SDK and then you start your gradle build which will download many dependent jar files from public maven repositories. This takes a considerable amount of time (many minutes).
Since the build uses the gradle build system it is easily possible to run multiple gradle script commands in one job, without sacrificing the build reliability (gradle clean will remove all prior build artifacts and restore a valid known state).

Feature checklist

Make sure these are completed before closing the issue, with a link to the relevant commit.