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

Relay Jenkins events to Github Action workflows #289

Merged
merged 2 commits into from
Dec 7, 2020

Conversation

phillipj
Copy link
Member

These changes are meant to allow us to write GitHub Actions in selected repositories in the nodejs github organization, as a reaction to Jenkins events.

It works by dispatching repository events, which we can use as triggers for GitHub Action workflows.

Here's a concrete repository dispatch event caused by the Jenkins job node-test-commit-osx:

event_type: jenkins.node-test-commit-osx.start or jenkins.node-test-commit-osx.end

client_payload:
{
  "identifier": "node-test-commit-osx",
  "status": "success",
  "message": "tests passed",
  "commit": "8a5fec2a6bade91e544a30314d7cf21f8a200de1",
  "url": "https://ci.nodejs.org/job/node-test-commit/3157/",
  "ref": "refs/pull/12345/head"
}

Refs:

mmarchini and others added 2 commits November 29, 2020 21:10
These changes are meant to allow us to write GitHub Actions in selected
repositories in the nodejs github organization, as a reaction to
Jenkins events.

It works by dispatching repository events, which we can use as triggers
for GitHub Action workflows.

Here's a concrete repository dispatch event caused by the Jenkins job
`node-test-commit-osx`:

```
event_type: jenkins.node-test-commit-osx.start or jenkins.node-test-commit-osx.end

client_payload:
{
  "identifier": "node-test-commit-osx",
  "status": "success",
  "message": "tests passed",
  "commit": "8a5fec2a6bade91e544a30314d7cf21f8a200de1",
  "url": "https://ci.nodejs.org/job/node-test-commit/3157/",
  "ref": "refs/pull/12345/head"
}

```

Refs:
    - https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
    - https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#create-a-repository-dispatch-event
@phillipj phillipj requested a review from a team as a code owner November 29, 2020 20:18
@phillipj
Copy link
Member Author

phillipj commented Dec 7, 2020

Thanks for having a look @mmarchini! Since you know the practical use cases better than me, I'd love your feedback on the following ramblings...

On second thought, I've got some doubts with regards to the event type names suggested with these changes. Especially having the job names, like node-test-commit-osx, as part of event type names in mind 🤔

Trying to put myself in the using end of these dispatched events, I get concerned they'll end up being awkward to consume:

on:
  repository_dispatch:
    types: [ jenkins.node-test-commit-osx.start, jenkins.node-test-linter.start, jenkins.node-test-pull-request.start ] # ..and the list goes on

Would it make sense to use jenkins.job.start | jenkins.job.end instead:

on:
  repository_dispatch:
    types: [ jenkins.job.start ]

and then filter on github.event.client_payload.identifier when needed?

@mmarchini
Copy link
Contributor

Oh, I didn't include one of my ideas in the PR. We could have wildcards: jenkins.node-test-commit-osx.start, jenkins.*.start, jenkins.node-test-commit-osx.*, jenkins.*.*. But that leads to quad-dispatching. Personally, I think folks will be interested in one Job instead of many. We can change that in the future if folks come up with use cases where multiple jobs are needed.

@phillipj
Copy link
Member Author

phillipj commented Dec 7, 2020

Ahhh alrighty then, let's go with this as is.

@phillipj phillipj merged commit c541205 into nodejs:master Dec 7, 2020
@phillipj phillipj deleted the relay-jenkins-to-gh-actions branch December 7, 2020 20:41
@phillipj
Copy link
Member Author

phillipj commented Dec 7, 2020

It's alive.

{
  "name": "bot",
  "hostname": "infra-rackspace-debian8-x64-1",
  "pid": 27894,
  "req_id": "a66d6390-38cd-11eb-a22b-f5ad452d226c",
  "identifier": "node-test-commit-aix",
  "event": "end",
  "level": 20,
  "msg": "Relaying jenkins.node-test-commit-aix.end to nodejs/node",
  "time": "2020-12-07T20:49:07.658Z",
  "v": 0
}

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

Successfully merging this pull request may close these issues.

2 participants