Skip to main content

Jenkins construct for CDK8s

Project description

cdk8s-jenkins

cdk8s-jenkins is a library that lets you easily define a manifest for deploying a Jenkins instance to your Kubernetes cluster.

Prerequisites

This library uses a Custom Resource Definition provided by jenkins, and thus requires both the CRD and the operator to be installed on the cluster. You can set this up by,

  1. Apply the Custom Resource Definition(CRD) for jenkins on your Kubernetes cluster.
kubectl apply -f https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/config/crd/bases/jenkins.io_jenkins.yaml
  1. Install the Jenkins Operator on your Kubernetes cluster.
kubectl apply -f https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/deploy/all-in-one-v1alpha2.yaml

For more information regarding applying jenkins crd and installing jenkins operator, please refer jenkins official documentaion.

Usage

The library provides a high level Jenkins construct to provision a Jenkins instance. You can just instantiate the Jenkins instance and that would add a Jenkins resource to the kubernetes manifest.

The library provide a set of defaults, so provisioning a basic Jenkins instance requires no configuration:

import { Jenkins } from 'cdk8s-jenkins';

// inside your chart:
const jenkins = new Jenkins(this, 'my-jenkins');

The library also enables configuring the following parmeters for the Jenkins instance:

metadata

const jenkins = new Jenkins(this, 'my-jenkins', {
  metadata: {
    namespace: 'jenkins-namespace',
    labels: { customApp: 'my-jenkins' },
  },
});

disableCsrfProtection

This allows you to toggle CSRF Protection for Jenkins.

const jenkins = new Jenkins(this, 'my-jenkins', {
  disableCsrfProtection: true,
});

basePlugins

These are the plugins required by the jenkins operator.

const jenkins = new Jenkins(this, 'my-jenkins', {
  basePlugins: [{
    name: 'configuration-as-code',
    version: '1.55',
    }],
});

You can also utilize addBasePlugins function to add base plugins to jenkins configuration after initialization.

const jenkins = new Jenkins(this, 'my-jenkins');
jenkins.addBasePlugins([{
  name: 'workflow-api',
  version: '2.76',
}]);

plugins

These are the plugins that you can add to your jenkins instance.

const jenkins = new Jenkins(this, 'my-jenkins', {
  plugins: [{
    name: 'simple-theme-plugin',
    version: '0.7',
    }],
});

You can also utilize addPlugins function to add plugins to jenkins configuration after initialization.

const jenkins = new Jenkins(this, 'my-jenkins');
jenkins.addPlugins([{
  name: 'simple-theme-plugin',
  version: '0.7',
}]);

seedJobs

You can define list of jenkins seed job configurations here. For more info you can take look at jenkins documentation.

const jenkins = new Jenkins(this, 'my-jenkins', {
  seedJobs: [{
    id: 'jenkins-operator',
    targets: 'cicd/jobs/*.jenkins',
    description: 'Jenkins Operator repository',
    repositoryBranch: 'master',
    repositoryUrl: 'https://github.com/jenkinsci/kubernetes-operator.git',
    }],
});

You can also utilize addSeedJobs function to add seed jobs to jenkins configuration after initialization.

const jenkins = new Jenkins(this, 'my-jenkins');
jenkins.addSeedJobs([{
  id: 'jenkins-operator',
  targets: 'cicd/jobs/*.jenkins',
  description: 'Jenkins Operator repository',
  repositoryBranch: 'master',
  repositoryUrl: 'https://github.com/jenkinsci/kubernetes-operator.git',
}]);

Using escape hatches

You can utilize escape hatches to make changes to the configurations that are not yet exposed by the library.

For instance, if you would like to update the version of a base plugin:

const jenkins = new Jenkins(this, 'my-jenkins');
const jenkinsApiObject = ApiObject.of(jenkins);
jenkinsApiObject.addJsonPatch(JsonPatch.replace('/spec/master/basePlugins/1', {
  name: 'workflow-job',
  version: '3.00',
}));

For more information regarding escape hatches, take a look at cdk8s documentation.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk8s_jenkins-0.0.559.tar.gz (158.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdk8s_jenkins-0.0.559-py3-none-any.whl (156.8 kB view details)

Uploaded Python 3

File details

Details for the file cdk8s_jenkins-0.0.559.tar.gz.

File metadata

  • Download URL: cdk8s_jenkins-0.0.559.tar.gz
  • Upload date:
  • Size: 158.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.14.3

File hashes

Hashes for cdk8s_jenkins-0.0.559.tar.gz
Algorithm Hash digest
SHA256 1f22a21c390abc7f4e780a77a8419a57baba94d74cd91d22101fc53f215cde1b
MD5 e2d1b2dca9d3bdcc5df2e8ff3aa55533
BLAKE2b-256 c6993f4688c0934a3b5009aa054bef93448a39101163ef2f38385537c8bef84c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdk8s_jenkins-0.0.559.tar.gz:

Publisher: release.yml on cdk8s-team/cdk8s-jenkins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cdk8s_jenkins-0.0.559-py3-none-any.whl.

File metadata

File hashes

Hashes for cdk8s_jenkins-0.0.559-py3-none-any.whl
Algorithm Hash digest
SHA256 eb685a01eb912f0adcb24d98b3fb2cb2cff5b8a229a5073fc3d1c19fcde152e5
MD5 947f0daab02c0d3c49756c30427130c9
BLAKE2b-256 abc5e96b8fa2eee8d535efcd07d05b88f567408ad869c6638022ad0352518600

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdk8s_jenkins-0.0.559-py3-none-any.whl:

Publisher: release.yml on cdk8s-team/cdk8s-jenkins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page