Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using multiple templates per .drone.yml file #27

Open
andrii-kasparevych opened this issue Jun 10, 2022 · 4 comments
Open

Allow using multiple templates per .drone.yml file #27

andrii-kasparevych opened this issue Jun 10, 2022 · 4 comments
Assignees

Comments

@andrii-kasparevych
Copy link

andrii-kasparevych commented Jun 10, 2022

As a Dev/DevOps I want a more agile way to manage the code duplication across the pipelines using templates. As of now the templates are allowed to use only once per pipeline, meaning there's no way to define a template for one pipeline and have a repo's .drone.yml using several templates that would kick off different (or same) pipelines with different parameters.
Example.
I have an app that I want to build for 3 different platforms (e.g. Windows, iOS, Android). The way I do it without a template is:

---
kind: pipeline
name: build-windows
... 300 lines of pipeline definition
---
kind: pipeline
name: build-iOS
... 300 lines of pipeline definition
---
kind: pipeline
name: build-android
... 300 lines of pipeline definition
---
kind: pipeline
name: report-to-slack
depends_on:
  - build-windows
  - build-android
  - build-iOS

The build pipelines are identical with a small difference in some command line arguments, but quite large (300 lines).
The report pipeline waits for the others to finish, gathers the results and reports to slack.
It would great to leverage templates on the level of build pipeline here, so that the amount of code duplication reduces significantly.
As a result the above would change to smth like this:

---
kind: template
name: build-windows
load: build.template.yaml
data:
  targetPlatform: Windows
---
kind: template
name: build-iOS
load: build.template.yaml
data:
  targetPlatform: iOS
---
kind: template
name: build-android
load: build.template.yaml
data:
  targetPlatform: Android
---
kind: pipeline
name: report-to-slack
depends_on:
  - build-windows
  - build-android
  - build-iOS
@mrsantons
Copy link
Contributor

Hey 👋🏻 @andrii-kasparevych

Thanks for submitting your proposal. We usually review PRs every Tuesday but I will keep you up to date if anything changes. 🎉

@bradrydzewski
Copy link
Member

I do want to clarify that a template yaml can contain multiple pipelines, however, a .drone.yml can only contain a single template. I completely agree that we should support multiple templates in the drone.yml file. I do think the current implementation could support your use case, as an immediate workaround.

@AmitBaranes
Copy link

@bradrydzewski This is a mandatory feature and this workaround is a bit messy. any ETL ?

@andrii-kasparevych
Copy link
Author

andrii-kasparevych commented Jul 18, 2022

@bradrydzewski thanks for that, I'm aware of the current capabilities. More than that - I've also built a separate repository for storing templates so that they are also version-controlled somehow and built an automation for auto-deployment to the drone server. If anyone is interested in details, I'm happy to share.

But still I think the feature of using multiple templates per .drone.yml is a must. I can think of an alternative approach - allow having more than one .drone.yml file per repository - each could contain 1 or more pipelines and just 1 template. That could also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants