Jenkins

Resources

Cheatsheet

Create credentials programatically

HTTP API

Specific Job API

  • $JENKINS_URL/<Job>/api

Specific Pipeline API

  • $JENKINS_URL/<Pipeline>/api

View Configuration as Code of Jenkins instance

  • $JENKINS_URL/manage/configuration-as-code/viewExport

JSON Schema

  • $JENKINS_URL/manage/configuration-as-code/schema

Job

  • Job types

    • Freestyle project

    • Pipeline

    • Multibranch Pipeline

  • Job DSL can be used to create Jobs such as Pipelines.

Job DSL

CLI

Jenkins CLI

  • $JENKINS_URL/jnlpJars/jenkins-cli.jar

Plugin Installation Manager Tool

Configuration as Code

Pipeline

Shared Library

Pipeline Snippet Generator

  • $JENKINS_URL/pipeline-syntax

Directive Generator

  • $JENKINS_URL/directive-generator

Steps Reference

  • $JENKINS_URL/pipeline-syntax/html

Global Variables Reference

  • $JENKINS_URL/pipeline-syntax/globals

Debugg Pipeline as Code

  • Use Replay to make ad-hoc edits to Pipeline code, and run the Pipeline, repeat until done, copy the code to VCS for future deployments.

Multibranch Pipeline

  • Jenkins automatically discovers, manages, and executes jobs for multiple source repositories and branches.

  • A multi-branch pipeline project always includes a Jenkinsfile in its repository root. Jenkins automatically creates a sub-project for each branch that it finds in a repository with a Jenkinsfile.

  • Resources

Jenkins Templating Engine

Tips

Retrieve Job configuration XML

  • Declarative Pipeline upon execution are converted to configuration in XML format.
  • To retrieve the config after conversion, use $JENKINS_URL/job/<job-name>/config.xml

Convert Job DSL to configuration XML

Use Job configuration XML to guide authoring Job DSL

Caveats

  • Pipeline script from SCM

    • GitLab Personal Access Token is not supported as credentials