Skip to content
circle

GitHub Action

Setup Jenkins

v1.1.0 Latest version

Setup Jenkins

circle

Setup Jenkins

Set up Jenkins container

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Setup Jenkins

uses: snow-actions/[email protected]

Learn more about this action in snow-actions/setup-jenkins

Choose a version

Test

Setup Jenkins

Set up Jenkins container.

Usage

  1. Copy $JENKINS_HOME/jobs/*/config.xml from existing Jenkins to jenkins_home/ in your repository
    or you can put jenkins_home/jenkins.yaml if Jenkins Configuration as Code (JCasC)
  2. Create a workflow with the jenkins_home path
steps:
  - uses: actions/checkout@v3
  - uses: snow-actions/[email protected]
    with:
      jenkins_home: jenkins_home
  - run: wget $JENKINS_URL/jnlpJars/jenkins-cli.jar
  - run: java -jar jenkins-cli.jar -webSocket help
  - run: java -jar jenkins-cli.jar -webSocket build job-1 -f -v -p param_1=p1

Install plugins

Recommended plugins are installed by default.

Add plugins

Install plugins in addition to recommended plugins.

steps:
  - uses: snow-actions/[email protected]
  - run: wget $JENKINS_URL/jnlpJars/jenkins-cli.jar
  - name: Short name
    run: java -jar jenkins-cli.jar -webSocket install-plugin git -deploy
  - name: URL
    run: java -jar jenkins-cli.jar -webSocket install-plugin https://updates.jenkins.io/latest/http_request.hpi -deploy

Override plugins

Recommended plugins are not installed.

steps:
  - uses: snow-actions/[email protected]
    with:
      plugins: |
        git
        http_request

Inputs

See action.yml

Name Description Default Required
jenkins_image_tag Jenkins image tag lts-jdk11 no
jenkins_home Jenkins home path which will be
mounted to /var/jenkins_home.
Set '' if you don't want to mount.
${{ runner.temp }}/jenkins_home no
env_file Jenkins container env_file path - no
plugins Override plugins.txt
@ installs recommended plugins.
@ no

Output environment variables

Name Description
JENKINS_HOME Path to jenkins_home
JENKINS_VERSION Jenkins version
JENKINS_URL Jenkins URL: http://localhost:8080
COMPOSE_FILE Docker Compose variable as same as --file, -f option
You can access Jenkins container by docker compose exec jenkins <command>

Examples

Workflow

See test.yml

Jenkins Configuration as Code (JCasC)

See jenkins.yaml

Documents

Supported

Runners

  • ubuntu-22.04
  • ubuntu-20.04
  • self-hosted

Events

  • Any

Dependencies

Contributing

Welcome.