'Gitlab CI: Using "environment" key with trigger in job
I am looking to use the environment keyword as shown below in job which has trigger.
deploy:
stage: deploy
environment:
name: develop
variables:
ENV: develop
trigger:
include:
- local: '<path to pipeline config>'
However, it is giving error "config contains unknown keys: environment"
It is working fine using "script" instead of trigger. Anyway it works with trigger ?
Solution 1:[1]
You can't set environment on bridge jobs. You must set environment.name
on the triggered job in the included config.
Solution 2:[2]
Yes apparently thats not allowed. I also felt this error and was expecting the environment config to be applicable on the child pipeline like below
sit-pipeline:
trigger:
include:
- local: pipeline/sit-pipeline.yaml
stage: deploy
when: manual
needs: ["sit-approval"]
environment:
name: sit
url: http://sanjay-sit.com
But this gives an error This GitLab CI configuration is invalid: sit-pipeline config contains unknown keys: environment.
It would have been a good feature especially when we want to put some approval process and protect the environment.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | sytech |
Solution 2 | Sanjay Bharwani |