Better failure if there are no variables

Migrated issue

Reported by: jonathan1055

Related to !267 (merged)

Problem/Motivation

I helped on a recent support request on Slack where the user did not know why the phpunit tests were not being attempted. I showed that they had a single SKIP_PHPUNIT: 1 variable defined in the .gitlab-ci.yml which had been copied from another project. The user removed the variable and then the pipeline completely fell in a heap, the composer job failed right at the start and they did not know what had gone wrong. What they had done was delete the SKIP_PHPUNIT: 1 line but leave in the variables: line. As this had been the only defined variable it had the effect of erasing every pre-defined variable, and the composer job just showed:

ERROR: Job failed: prepare environment: waiting for pod running: image pull failed: Failed to apply default image tag "/php--:": couldn't parse image name "/php--:": invalid reference format. 

I recognised the derived image string "/php--:" as being the base string with all constituent variables blank, so I could deduce what had happened. But that's only because I have worked on this project - most developers would not have any idea what they had done wrong.
Here is the pipeline and here's the MR

Steps to reproduce

Run a pipeline with variables: but no actual variable defined below it.

Proposed resolution

Add a job to the .pre section that will only run if some critical variables are empty, and give a helpful message to explain what might have gone wrong.

Remaining tasks

User interface changes

API changes

Data model changes

Assignee Loading
Time tracking Loading