Skip to content

Github Action to trigger Jenkins job using Jenkins API and wait until completion

License

Notifications You must be signed in to change notification settings

estherk0/jenkins-trigger

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins job trigger action

Github Action to trigger jenkins job and wait for job completion using Jenkins API.
Welcome your feedback and request. 👐

Usage

Generate API token for Jenkins API

Please see How to get the API Token for Jenkins

  1. Log in Jenkins.
  2. Click you name (upper-right corner).
  3. Click Configure (left-side menu).
  4. Use "Add new Token" button to generate a new one then name it.
  5. You must copy the token when you generate it as you cannot view the token afterwards.
  6. Revoke old tokens when no longer needed.

Inputs

name required description
url true Jenkins full URL including http/https protocol
user_name true User name of Jenkins
api_token true Jenkins API token
job_name true Jenkins job name
parameter false Job parameter in JSON format. ex) {"param1":"value1"}
headers false Additional headers to include in the HTTP requests in JSON format. ex) {"param1":"value1"}
wait false Set true as default. Waiting for job completion or not
timeout false Set 600 seconds as default. Timeout (seconds) for github action.

Example

- name: Trigger jenkins job
  uses: jabbukka/jenkins-trigger@main
  with:
    url: ${{ secrets.JENKINS_URL }}
    job_name: "build_web_application"
    user_name: ${{ secrets.JENKINS_USER }}
    api_token: ${{ secrets.JENKINS_TOKEN }}
    wait: "true"
    timeout: "1000"