Jenkinsfile Runner Action for GitHub Actions

Goal: Implement a (near) feature-complete version of Jenkinsfile Runner Action for GitHub Actions

Status: Selected

Team

Details

Abstract

Jenkinsfile Runner Action for GitHub Actions provides the customized containerized environment and useful GitHub Actions for users to run the Jenkins pipeline inside GitHub Actions. In more detail, if using these actions, any GitHub project which has a Jenkinsfile can execute its workflow in the GitHub Actions runner. It aims at applying Jenkins in the GitHub Actions in a Function-as-a-Service context. This feature is based on the Jenkinsfile Runner, which is a command line tool for the Jenkins pipeline execution engine. The user can define the Jenkins pipeline environment by extending several Vanilla images and configuring the Jenkins Configuration-as-Code plugin.

Rationale

The Jenkins pipeline environment includes the Jenkins core war package, the Jenkinsfile Runner, and at a minimum a required set of plugins to run the pipeline. All the dependencies are incorporated into the containers. As the GitHub Actions support using the predefined containers and building custom images, the containers - which include the Jenkins runtime - are able to start inside the GitHub Actions.

Implementation

Jenkinsfile Runner Action for GitHub Actions defines the dependencies in the prebuilt container and wraps the entrypoint in one GitHub Action so that the users can call the running environment and the related GitHub Action in their workflow definitions. The decoupling of environment declaration and Jenkinsfile Runner Action enables the users to utilize other useful GitHub Actions. This project will provide several vanilla images including necessary dependencies to run the Jenkins pipeline. Users can extend these images to set up their customized environment. What’s more, the user can install the plugins, which is enabled by Plugin Installation Manager Tool, and then configure Jenkins, which is enabled by Configuration-as-Code plugin. We’ll also provide examples about how to store the pipeline artifacts, how to use the Jenkins secrets and environmental variables, how to use the cache to accelerate the pipeline, etc. By providing these examples and iterating the current actions, we want the Jenkins pipeline to fit into the Cloud Native model gradually in the GitHub Actions context.

Examples

We recommend using either of two Jenkinsfile Runner Actions based on the container idea.

  • jfr-container-action - If the job in workflow uses this action, it can run the pipeline by specifying Jenkinsfile and integrate with other GitHub Actions such as actions/setup-java. As it’s based on the idea of Running jobs in a container, the user needs to declare the image usage of jenkins/jenkinsfile-runner at the start of the job. The users can call this action by using Cr1t-GYM/jenkins-action-poc/jfr-container-action@master. An example about how to use this action can be found at in the POC project. Its function invocation in the workflow definition looks like the following:

container:
  # prerequisite
  image: jenkins/jenkinsfile-runner
steps:
  - uses: actions/checkout@v2
  # jfr-container-action function interface
  - uses:
      Cr1t-GYM/jenkins-action-poc/jfr-container-action@master
    with:
      command: run
      jenkinsfile: Jenkinsfile
      pluginstxt: plugins.txt
      jcasc: jcasc.yml
  • jfr-static-image-action - This action can also run the pipeline. However, because of the late-start nature of the Jenkins container, this action is expected to experience strong isolation from the host machine. Therefore, the users cannot use other GitHub Actions except using actions/checkout to set up the workspace. The users can call this action by using Cr1t-GYM/jenkins-action-poc/jfr-static-image-action@master. An example about how to use this action can be found at in the POC project. Its function invocation in the workflow definition looks like the following:

steps:
  - uses: actions/checkout@v2
  # jfr-static-image-action function interface
  - uses:
      Cr1t-GYM/jenkins-action-poc/jfr-static-image-action@master
    with:
      command: run
      jenkinsfile: Jenkinsfile
      pluginstxt: plugins.txt
      jcasc: jcasc.yml

Chat

We use the #gsoc-jenkinsfile-runner channel in the CDF Slack workspace.

Explanations about the CDF Slack (the invitation link is at the end of the paragraph).

Office hours

Links