validate_job!

in lib/gitlab_ci_yaml_processor.rb [144:185]


  def validate_job!(name, job)
    job.keys.each do |key|
      unless ALLOWED_JOB_KEYS.include? key
        raise ValidationError, "#{name}: unknown parameter #{key}"
      end
    end

    if !job[:script].is_a?(String) && !validate_array_of_strings(job[:script])
      raise ValidationError, "#{name}: script should be a string or an array of a strings"
    end

    if job[:stage]
      unless job[:stage].is_a?(String) && job[:stage].in?(stages)
        raise ValidationError, "#{name}: stage parameter should be #{stages.join(", ")}"
      end
    end

    if job[:image] && !job[:image].is_a?(String)
      raise ValidationError, "#{name}: image should be a string"
    end

    if job[:services] && !validate_array_of_strings(job[:services])
      raise ValidationError, "#{name}: services should be an array of strings"
    end

    if job[:tags] && !validate_array_of_strings(job[:tags])
      raise ValidationError, "#{name}: tags parameter should be an array of strings"
    end

    if job[:only] && !validate_array_of_strings(job[:only])
      raise ValidationError, "#{name}: only parameter should be an array of strings"
    end

    if job[:except] && !validate_array_of_strings(job[:except])
      raise ValidationError, "#{name}: except parameter should be an array of strings"
    end

    if job[:allow_failure] && !job[:allow_failure].in?([true, false])
      raise ValidationError, "#{name}: allow_failure parameter should be an boolean"
    end
  end