https://github.com/optimizely/remote-jenkins-job
Trigger a Remote Jenkins Job with parameters and get console output as well as result
https://github.com/optimizely/remote-jenkins-job
Last synced: 10 months ago
JSON representation
Trigger a Remote Jenkins Job with parameters and get console output as well as result
- Host: GitHub
- URL: https://github.com/optimizely/remote-jenkins-job
- Owner: optimizely
- License: apache-2.0
- Archived: true
- Created: 2018-01-17T21:31:48.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-05-11T05:04:20.000Z (almost 4 years ago)
- Last Synced: 2025-03-16T13:42:15.315Z (12 months ago)
- Language: Shell
- Size: 8.79 KB
- Stars: 16
- Watchers: 72
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# remote-jenkins-job
Trigger a Remote Jenkins Job with parameters and get console output in real time, as well as result (pass/fail)
## Background
This script is intended to replace the Jenkins
[Parameterized Remote Trigger Plugin](https://wiki.jenkins.io/display/JENKINS/Parameterized+Remote+Trigger+Plugin).
At the time of writing this, the plugin appears unmaintained and the last commit was sometime in August, 2015. Recent Jenkins updates have made this plugin extremely unstable, resulting in frequent `NullPointerError` failures.
## Requirements
jq, curl, Jenkins
## Usage
Extremely simple, use as follows:
`remote-job.sh -u https://jenkins-url.com -j JOB_NAME -p "PARAM1=999" -p "PARAM2=123" -t BUILD_TOKEN -i`
Where the following parameters are set:
* `-u`: url of jenkins host
* `-j`: JOB_NAME on jenkins host (eg master-build).
* `-p`: parameter(s) to pass in. Send multiple parameters by passing in multiple `-p` flags.
* `-t`: BUILD_TOKEN on remote machine to run job
* `-i`: ignore certificate validation (useful if you see curl SSL errors while polling)
You can optionally set the polling interval (`POLL_INTERVAL`, default 5) and build timeout (`BUILD_TIMEOUT_SECONDS`, default 3600) as environment variables.
The script will poll the job until completion, and output the console of the running job in near-real time as it is updated. It does this by setting a cursor on the last line received and only outputting new lines (using a simple tail -n command).
## Notes
Currently the script outputs all parameters (including tokens) for logging purposes. You may want to implement a mask on any sensitive fields like tokens through Jenkins password fields.