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

Support arbitrary action value from parameter in query string #3341

Conversation

filippopisano
Copy link

@filippopisano filippopisano commented Jul 27, 2023

Support arbitrary values for action in the Build Create API handler

Current implementation

Currently, when we create a build via REST API there is no straightforward way to target a specific pipeline if more than one custom event is present

---
kind: pipeline
type: docker
name: myaction1

steps:
- name: test
  image: node:9.8.0
  commands:
  - "echo MyAction1"

trigger:
  events:
    - custom
---
kind: pipeline
type: docker
name: myaction2

steps:
- name: test
  image: node:9.8.0
  commands:
  - "echo MyAction2"

trigger:
  events:
    - custom

In the example above both pipelines will be executed when the Build Create endpoint is called.

New implementation

---
kind: pipeline
type: docker
name: myaction1

steps:
- name: test
  image: node:9.8.0
  commands:
  - "echo MyAction1"

trigger:
  events:
    - custom
  # New parameter passed via Query String
  action:
    - myaction1

---

kind: pipeline
type: docker
name: myaction2

steps:
- name: test
  image: node:9.8.0
  commands:
  - "echo MyAction2"

trigger:
  events:
    - custom

  # New parameter passed via Query String
  action:
    - myaction2

Adding action in the trigger section will allow us to target only specific pipelines with a simple paramenter in the REST API:
curl -X POST -H "Authorization: Bearer <token>" https://hostname.com/api/repos/filippopisano/drone-test-repo/builds?action=myaction1

and

curl -X POST -H "Authorization: Bearer <token>" https://hostname.com/api/repos/filippopisano/drone-test-repo/builds?action=myaction2

@CLAassistant
Copy link

CLAassistant commented Jul 27, 2023

CLA assistant check
All committers have signed the CLA.

@filippopisano filippopisano marked this pull request as ready for review July 27, 2023 07:40
@tphoney tphoney merged commit 5075f84 into harness:master Aug 9, 2023
2 checks passed
@tphoney
Copy link

tphoney commented Aug 9, 2023

thanks for the PR, merged !

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

Successfully merging this pull request may close these issues.

None yet

4 participants