
Manage Jenkins jobs, folders, views, and credentials declaratively with Terraform.
Community provider — not supported by HashiCorp.
Quick Start
terraform {
required_providers {
jenkins = {
source = "namecheap/jenkins"
version = "~> 1.0"
}
}
}
provider "jenkins" {
server_url = "https://jenkins.example.com"
username = var.jenkins_username
password = var.jenkins_api_token # API token recommended over password
}
resource "jenkins_folder" "team" {
name = "platform-team"
description = "Platform team pipelines"
}
resource "jenkins_credential_username" "github" {
name = "github-bot"
folder = jenkins_folder.team.id
username = "github-bot"
password = var.github_token
}
resource "jenkins_job" "deploy" {
name = "deploy-backend"
folder = jenkins_folder.team.id
template = templatefile("${path.module}/pipeline.xml", {
credentials_id = jenkins_credential_username.github.id
})
}
Resources
Data Sources
Provider Configuration
provider "jenkins" {
server_url = "https://jenkins.example.com" # or $JENKINS_URL
username = "admin" # or $JENKINS_USERNAME
password = "api-token" # or $JENKINS_PASSWORD
ca_cert = "/path/to/ca.pem" # optional: custom CA
insecure = false # optional: skip TLS verify
}
| Argument |
Environment variable |
Description |
server_url |
JENKINS_URL |
Jenkins base URL |
username |
JENKINS_USERNAME |
Jenkins username |
password |
JENKINS_PASSWORD |
Jenkins API token or password |
ca_cert |
JENKINS_CA_CERT |
Path to a custom CA certificate |
insecure |
— |
Skip TLS certificate verification (non-production only) |
Developing the Provider
Requirements:
Build & local install:
make build
# Prints the ~/.terraformrc dev_overrides snippet — add it to use the local build.
Run tests:
make test # unit tests (no Docker needed)
make testacc # acceptance tests — starts Jenkins via Docker Compose
make lint # golangci-lint + govulncheck
make generate # regenerate docs/ from provider schema
Integration tests use terraform test against a Docker-managed Jenkins:
ssh-keygen -t ed25519 -N "" -f integration/credentials/id_ed25519
cd integration && terraform init && terraform test
Update docs after any schema change:
make generate # re-renders docs/ from provider schema + examples/
git diff docs/ # verify changes look correct before committing
Attribution
Provider design inspired by dihedron/terraform-provider-jenkins.