Need some help with configuration .gitlab-ci.yml to implement the keyword 'needs'

I need some help to implement the keyword “needs” in my yml file, I want to make the dependency between jobs.
For example, I want that one job by schedules checks the device “Connected or not to PC” then if connected the second job runs. I read that with the keyword “needs” it is possible to do.

My Yml file.

I checked syntax it is correct, see below attacment.

But when commit these changes in the repository I have the error.

Can SomeOne help me?

Thanks A lot.

Hi,

I’d say that variable resolution doesn’t work in array elements for needs, this likely needs a static job string name. Would qualify for a feature request though, mind creating one?

Cheers,
Michael

Hi. Thanks for the answer.
"this likely needs a static job string name" - U mean rename jobs, for example from " jobDetect:$UIDID_IPHONE_7_WHITE" to " jobDetect$UIDID_IPHONE_7_WHITE".

Thanks.

Hi,

I was under the impression that one could use variables to create dynamic job names. You are using this in a way that jobDetect:$UIDID_IPHONE_7_WHITE translates to something like this in your job list: jobDetect:123456789.

Wondering if that’s your intention with the $... notation, or if I am missing some feature here.

Actually the lexer/parser for the config supports that in the background, but does not automatically do that for job names this time.

https://gitlab.com/gitlab-org/gitlab/issues/28734

The config validation already defines a name either as string, or as symbol which makes me thing that this could be generated automatically.

lib/gitlab/ci/config (master=) $ vim entry/job.rb

          validations do
            validates :config, type: Hash
            validates :config, allowed_keys: ALLOWED_KEYS
            validates :config, required_keys: REQUIRED_BY_NEEDS, if: :has_needs?
            validates :config, presence: true
            validates :script, presence: true
            validates :name, presence: true
            validates :name, type: Symbol

          def name
            @metadata[:name]
          end

I’m still wondering why your pipeline fails. I’ve built one myself and it doesn’t fail.

https://gitlab.com/dnsmichi/ci-cd-playground/blob/b6353ba519930f6b20f54ca192afff7979b8e851/.gitlab-ci.yml

Cheers,
Michael

Thanks, for your explanation.