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

feiguoL/jenkins-trigger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 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: feiguoL/jenkins-trigger@main
  id: generate_url
  with:
    url: ${{ secrets.JENKINS_URL }}
    job_name: "build_web_application"
    user_name: ${{ secrets.JENKINS_USER }}
    api_token: ${{ secrets.JENKINS_TOKEN }}
    wait: "true"
    timeout: "1000"
- name: print_url
  run: |
    echo "pipeline run link url: ${{ steps.generate_url.outputs.jobUrl }}, runId: ${{ steps.generate_url.outputs.runId }}"

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%