Support `environment` keyword with `trigger` keyword (Parent-child/Multi-project pipelines)
DRI: @shinya.maeda ## Release notes If you prefer to trigger a separate CD pipeline from a CI pipeline run, GitLab long offered the `trigger` keyword. Until now, it was not possible to update an environment in the upstream project when the job triggered a downstream pipeline. As a further enhancement in deployment management functionalities, GitLab now supports specifying the environment together with triggering a downstream pipeline. ## Summary GitLab CI/CD has the feature [Multi-project pipelines](https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html) i.e. `trigger` keyword. Currently, there is no capability to annotate the downstream pipeline as the deployment pipeline with `environment` keyword. ## Use cases - https://gitlab.com/gitlab-org/gitlab/-/issues/350550#note_927438598 - https://gitlab.com/gitlab-org/gitlab/-/issues/350550#note_937350261 - https://gitlab.com/gitlab-org/gitlab/-/issues/350550#note_939434707 - https://gitlab.com/gitlab-org/gitlab/-/issues/350550#note_942436834 ## User experience goals Example: ``` deploy: trigger: project: some/other/repo branch: master environment: name: dev url: https://app.dev.blah.com ``` ## References * https://gitlab.com/groups/gitlab-org/-/epics/8483#note_1043928481 * https://gitlab.com/gitlab-com/gl-infra/platform/runway/team/-/blob/master/architecture.md * https://blog.developer.atlassian.com/why-atlassian-uses-an-internal-paas-to-regulate-aws-access/ <details> <summary>Previous description</summary> ### Steps to reproduce Gitlab CI will not allow using the `environment` key with a job that uses the `trigger` key, it produces `yaml invalid` error. In the Gitlab CI lint tool paste the following example: ``` deploy: trigger: project: some/other/repo branch: master environment: name: dev url: https://app.dev.blah.com ``` ### What is the current *bug* behavior? I get the following error in the UI: ``` Status: Syntax is incorrect. CI configuration validated, including all configuration added with the includes keyword. More information jobs:deploy config contains unknown keys: environment jobs:deploy config should contain either a trigger or a needs:pipeline ``` ### What is the expected *correct* behavior? I would expect this to be allowed, to configure an environment for a multi project trigger job. If it is not allowed then I don't think the docs communicate this: https://docs.gitlab.com/ee/ci/yaml/#environment ### Relevant logs and/or screenshots ![image](/uploads/6fd13b440f6e6ed52f2fc773e2ee3c7f/image.png) #### Results of GitLab environment info <details> <summary>Expand for output related to GitLab environment info</summary> <pre> System information System: Debian 9.13 Current User: git Using RVM: no Ruby Version: 2.7.5p203 Gem Version: 3.1.4 Bundler Version:2.1.4 Rake Version: 13.0.6 Redis Version: 6.0.16 Git Version: 2.33.1. Sidekiq Version:6.3.1 Go Version: unknown GitLab information Version: 14.6.0 Revision: 3bc07a0be9c Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.7 URL: https://git2.vizibl.co HTTP Clone URL: https://git2.vizibl.co/some-group/some-project.git SSH Clone URL: git@git2.vizibl.co:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 13.22.1 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git </pre> </details> #### Results of GitLab application Check <details> <summary>Expand for output related to the GitLab application check</summary> <pre> Checking GitLab subtasks ... Checking GitLab Shell ... GitLab Shell: ... GitLab Shell version >= 13.22.1 ? ... OK (13.22.1) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful Checking GitLab Shell ... Finished Checking Gitaly ... Gitaly: ... default ... OK Checking Gitaly ... Finished Checking Sidekiq ... Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1 Checking Sidekiq ... Finished Checking Incoming Email ... Incoming Email: ... Reply by email is disabled in config/gitlab.yml Checking Incoming Email ... Finished Checking LDAP ... LDAP: ... LDAP is disabled in config/gitlab.yml Checking LDAP ... Finished Checking GitLab App ... Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 9/3 ... yes 9/4 ... yes 10/5 ... yes 10/8 ... yes 10/10 ... yes 10/11 ... yes 10/12 ... yes 10/13 ... yes 10/14 ... yes 10/16 ... yes 10/18 ... yes 10/19 ... yes 10/20 ... yes 10/21 ... yes Redis version >= 5.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.5) Git version >= 2.33.0 ? ... yes (2.33.1) Git user has default SSH configuration? ... yes Active users: ... 14 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Checking GitLab App ... Finished Checking GitLab subtasks ... Finished </pre> </details> </details>
epic