简体   繁体   中英

Trigger GitHub Actions from Jenkins Pipeline using API/Actions Pluginfor Jenkins

I want to trigger the GitHub Actions using Jenkins Pipeline or Jenkins Job and send some build parameters as input for the GitHub Actions. I am doing this since there is no option of dropdown list for the GitHub Action Input parameters.

This is only half a solution. But there is an option to specify an input params list for GitHub actions.

See workflow_dispatch event type on GitHub actions. The current url is here: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch (If this stops working just google workflow_dispatch)

The other half (Jenkins triggering a GHA build), I am actually searching for myself too. I can find ones working in reverse. GHA triggering jenkins.

We can trigger Github action with rest api (POST) or curl requests. All you need to do create with workflow with dispatch trigger (repository_dispatch or workflow_dispatch)

on:
  workflow_dispatch:
    inputs:
      InputKey:
        type: string
        required: true

next trigger this workflow by one of the below methods

1. POST https://api.github.com/repos/ //dispatches Authorization: Bearer

{"event_type": "hello"}
  1. curl --request POST
    --url 'https://api.github.com/repos///dispatches'
    --header 'authorization: Bearer '
    --data '{"event_type": "hello"}'

Also specify the inputs in requests with --data '{"event_type": "<workflow name>","client_payload":{"<input_key>":"<input_value>"}}'

All you need to do now is put this request in your job (scripted pipeline is preferred) with appropriate values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM