Skip to content

IaC & CI/CD: Jenkins

Jenkins commands from the IaC & CI/CD folder.

Index
2 items

Jenkins: Tail a build's console log

Safe

Last 100 lines of the latest build's console without opening the UI.

curl -sS -u <user>:<api-token> "<jenkins-url>/job/<job>/lastBuild/consoleText" | tail -n 100
What each part does
  1. curl -sSquiet, but still show errors
  2. -u <user>:<api-token>basic auth with a Jenkins API token
  3. /job/<job>/lastBuild/consoleTextplain-text console output of the latest build (use a build number instead of lastBuild)
  4. | tail -n 100only the last 100 lines

Also known as: jenkins console · build log

Jenkins: Trigger a parameterized build

Safe

Start a job remotely with parameters via the REST API.

curl -X POST -u <user>:<api-token> "<jenkins-url>/job/<job>/buildWithParameters?<param>=<value>"
What each part does
  1. curl -X POSTtrigger endpoints need POST
  2. -u <user>:<api-token>basic auth with an API token (no CSRF crumb needed with a token)
  3. /job/<job>/buildWithParametersqueue a build of a parameterized job
  4. ?<param>=<value>job parameters, joined with &

Also known as: jenkins api · remote build

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…