Jobs stage config should implement a script: or a trigger: keyword. But trigger keyword already there

Hi Team,

I’m facing a issue with using trigger key word for parent child pipelines. I’m using gitlab free EE is that the reason to fail the pipeline with bellow error?

error:

jobs stage config should implement a script: or a trigger: keyword*

code:

trigger_terraform_plan:
stage: trigger_plan
rules:
- if: ( $aws_account != null )
trigger:
include: child_jobs/ymls/terraform_plan_template.yml*

could you please help me to fix it?

Hi @uyanushka

It’s hard to tell what’s happening here, but it would help if you could format your YAML snippet as a code block (use the </> button in the text editor).

I think you want something like this, but you will probably need to play around with this a little further:

trigger_terraform_plan:
    stage: trigger_plan
    rules:
        - if: ${aws_account}
          when: always
        - when: never
    trigger:
        include: child_jobs/ymls/terraform_plan_template.yml

This is based on the child pipeline docs and the rules docs.

1 Like

Hi @snim2

sorry forgot to format the code before, this is the formatted code. I’m getting error jobs stage config should implement a script: or a trigger: keyword * but in that stage we have trigger key word.

trigger_terraform_plan:
  stage: trigger_plan
  rules:
    - if: ( $aws_account != null )
  trigger:
   include: child_jobs/ymls/terraform_plan_template.yml*

OK, have you tried my version above? or something like it?

yes. I have tested with by removing if condition also, but same error occurred.

Is that due to free version when I was checking pricing I have noticed that advance pipeline are available on paid version.

The child pipeline docs say that parent-child pipelines are available in all tiers, so I don’t think the issue is that you are using the free plan. Also, that snippet passes the lint for me.

Is it possible to post your full .gitlab-ci.yml file?

1 Like

difficult to provide entire code here since this is big project. give me some time I’ll try to regenerate it with some simple pipeline.

Hi @snim2

apologize on delay reply, could be able to regenerate the issue with 2 simple files.

.gitlab-ci.yml

stages:
  - stage1
  - trigger

.base:
  image:
    name: ${BASE_CICD_IMAGE}
    entrypoint: [""]
  tags:     
    - "docker-in-docker"

stage_1:
  stage: stage1
  extends: .base
  script:
    - echo stage1

trigger:
  stage: trigger
  trigger:
    include:  child_jobs/ymls/terraform_plan_template.yml

child_jobs/ymls/terraform_plan_template.yml

stage:
  - plan

.base:
  image:
    name: ${BASE_CICD_IMAGE}
    entrypoint: [""]
  tags:     
    - "docker-in-docker"

terraform_plan:
  stage: plan
  extends: .base
  script: 
    - echo test

Hi @uyanushka

I’ve been facing a similar issue having this message:

* jobs artifacts config should implement a script: or a trigger: keyword

From that, I’ve realized a bad indentation for the “artifacts” item in a job - very complicated to find this kind of errors, I think Gitlab message should explicit the line number - then it would be easier to find it.

So, in your case,

** jobs stage config should implement a script: or a trigger: keyword

means that your job called “stage” is wrong. In your terraform_plan_template.yml, you’ve mistyped “stages” by writing “stage” - Gitlab thinks it is a job, and that’s why you are having the issue.

Again, I still think the error message is very misleading, it should either print the line number OR at least put the ‘stage’ word inside quotes.

Hope that helps.

BR,
Lucas

3 Likes

thanks, It solved my issue.

In my case i have missed a script section after before_script: then added it’s resolved my issue.

Thanks
Viswanath