2

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.

torek
  • 448,244
  • 59
  • 642
  • 775
vik_nag
  • 415
  • 1
  • 5
  • 7

2 Answers2

0

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.

Luke Hill
  • 460
  • 2
  • 10
0

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.

amit yadav
  • 51
  • 1
  • 1
  • 3