https://github.com/devkyt/jenkins-trigger
GitHub Action to trigger a job on Jenkins
https://github.com/devkyt/jenkins-trigger
github-actions jenkins triggers
Last synced: about 1 year ago
JSON representation
GitHub Action to trigger a job on Jenkins
- Host: GitHub
- URL: https://github.com/devkyt/jenkins-trigger
- Owner: devkyt
- Created: 2024-03-24T11:57:53.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-24T12:38:59.000Z (almost 2 years ago)
- Last Synced: 2025-01-20T19:38:08.956Z (about 1 year ago)
- Topics: github-actions, jenkins, triggers
- Language: Shell
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Annotations
The one-line GitHub Action to remotely trigger a job on Jenkins. You just need to pass 3 parameters to get it working:
| Parametr | Description |
| ------------- | ------------- |
| JENKINS_URL | URL of a Jenkins instance with specified job's path |
| JENKINS_USER | User from whose identity an API will be called |
| JENKINS_API_KEY | User's valid API key |
## How to use
Here is a example of how to trigger Jenkins job on every push to the staging or dev branch:
```yaml
name: Trigger Job on Jenkins
on:
push:
branches:
- staging
- dev
jobs:
trigger:
name: Trigger
runs-on: ubuntu-latest
steps:
- uses: devkyt/jenkins-trigger@main
with:
JENKINS_URL: https://my.jenkins.com/job/Pipelines/job/Frontend/buildWithParameters?BRANCH=dev&ENVIRONMENT=dev
JENKINS_USER: jenkins
JENKINS_API_KEY: set324sfvokom87ldfs
```
#### About URLs
The default job's URL looks like this: ```https://my.jenkins.com/job/Backend/build```.
But if your job supports input parameters then you should use ```buildWithParameters``` instead of the ```build``` at the end of the path. Even if you don't want to run the job with some actual params. Otherwise, you can provide them as a query ```https://my.jenkins.com/job/Backend/buildWithParameters?BRANCH=dev&ENVIRONMENT=dev```.
Below you will find a few examples of Jenkins job URLs.
| Type | Example |
| ------------- | ------------- |
| Common | https://my.jenkins.com/job/Backend/build |
| Multibranch | https://my.jenkins.com/job/Pipelines/job/Frontend/buildWithParameters |
| Common with params | https://my.jenkins.com/job/Backend/buildWithParameters?BRANCH=dev&ENVIRONMENT=dev |
| Multibranch with params | https://my.jenkins.com/job/Pipelines/job/Frontend/buildWithParameters?BRANCH=dev&ENVIRONMENT=dev|