home / skills / openclaw / skills / jenkins

jenkins skill

/skills/guoway/jenkins

This skill helps you manage Jenkins jobs, trigger builds, and monitor pipelines via API to streamline CI/CD workflows.

npx playbooks add skill openclaw/skills --skill jenkins

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
1.7 KB
---
name: jenkins
description: Interact with Jenkins CI/CD server via REST API. Use when you need to trigger builds, check build status, view console output, manage jobs, or monitor Jenkins nodes and queue. Supports deployment to different Jenkins instances via environment variables.
---

# Jenkins

Interact with Jenkins CI/CD server through REST API.

## Required environment variables

- `JENKINS_URL` (example: `https://jenkins.example.com`)
- `JENKINS_USER` (your Jenkins username)
- `JENKINS_API_TOKEN` (API token from Jenkins user settings)

## List jobs

```bash
node {baseDir}/scripts/jenkins.mjs jobs
node {baseDir}/scripts/jenkins.mjs jobs --pattern "deploy-*"
```

## Trigger build

```bash
node {baseDir}/scripts/jenkins.mjs build --job "my-job"
node {baseDir}/scripts/jenkins.mjs build --job "my-job" --params '{"BRANCH":"main","ENV":"dev"}'
```

## Check build status

```bash
node {baseDir}/scripts/jenkins.mjs status --job "my-job"
node {baseDir}/scripts/jenkins.mjs status --job "my-job" --build 123
node {baseDir}/scripts/jenkins.mjs status --job "my-job" --last
```

## View console output

```bash
node {baseDir}/scripts/jenkins.mjs console --job "my-job" --build 123
node {baseDir}/scripts/jenkins.mjs console --job "my-job" --last --tail 50
```

## Stop build

```bash
node {baseDir}/scripts/jenkins.mjs stop --job "my-job" --build 123
```

## View queue

```bash
node {baseDir}/scripts/jenkins.mjs queue
```

## View nodes

```bash
node {baseDir}/scripts/jenkins.mjs nodes
```

## Notes

- URL and credentials are variables by design for cross-environment deployment.
- API responses are output as JSON.
- For parameterized builds, use `--params` with JSON string.

Overview

This skill manages Jenkins jobs, builds, and pipelines through the Jenkins remote API. It lets you list jobs, trigger builds, and monitor build status programmatically. Designed for automation and integration with other tools or bots.

How this skill works

The skill talks to a Jenkins server using the Jenkins REST API and basic token-based authentication. It retrieves job lists and build metadata, sends build trigger requests, and polls build status endpoints to report progress and results. Environment variables store the server URL, username, and API token for secure, repeatable calls.

When to use it

  • Automating CI/CD steps from scripts, chatops, or external orchestrators.
  • Triggering ad-hoc or scheduled builds without logging into the Jenkins UI.
  • Monitoring build health and reporting status to dashboards or alerts.
  • Backing up or auditing job states across multiple Jenkins instances.
  • Integrating Jenkins actions into developer tools or chatbots.

Best practices

  • Store JENKINS_URL, JENKINS_USER, and JENKINS_TOKEN in environment variables or a secrets manager.
  • Use the Jenkins API endpoints that return JSON for stable parsing (avoid HTML scraping).
  • Rate-limit polling when checking build status to avoid stressing the server.
  • Scope API tokens with least privilege and rotate them regularly.
  • Handle HTTP errors and authentication failures gracefully with retries and clear logs.

Example use cases

  • List all jobs and filter by color/status to produce an overnight CI health report.
  • Trigger a downstream pipeline from a chat command and return the build link to the user.
  • Poll the last build endpoint to detect failures and forward failure details to a ticket or alert system.
  • Automate backup or export of job configurations by enumerating jobs and fetching their XML definitions.

FAQ

What credentials are required?

A Jenkins username and API token with permission to list jobs and trigger builds. Store them securely as environment variables.

How do I check build progress?

Query the job's lastBuild API JSON endpoint and read fields like result, building, and duration to determine progress and outcome.