This is the demo project for the original POC project. It teaches the users how to use Jenkinsfile-runner Actions.
All the demos are stored in the ./demo
directory. You can use them with jenkinsfile-runner-action
, jfr-container-action
and jfr-static-image-action
.
- Java demo: It's a Spring Boot project. The source files are generated by Spring Initializr.
- JavaScript demo: It's a React project. You can generate it by using
npm init react-app ./my-react-app
in the command line. - Scala demo: It's a Scala project. You can generate it by using
sbt new scala/scalatest-example.g8
in the command line. - Jenkins secrets demo: It teaches you how to define and use secrets in the Jenkins pipeline.
- Jenkins environment variables demo: It teaches you how to define and use environment variables in the Jenkins pipeline.
- s3-artifact-manager demo: It teaches you how to store the pipeline results to an external storage.
- jobcacher demo: It teaches you how to cache the pipeline dependencies.
- remote agent demo: It teaches you how to trigger the building in the remote agents.
Reference these actions in your workflow definition.
- Cr1t-GYM/jenkins-action-poc/jenkins-plugin-installation-action@master
- Cr1t-GYM/jenkins-action-poc/jenkinsfile-runner-action@master
- Cr1t-GYM/jenkins-action-poc/jenkins-setup@master
- Cr1t-GYM/jenkins-action-poc/jfr-container-action@master
- Cr1t-GYM/jenkins-action-poc/jfr-static-image-action@master
- Prepare a Jenkinsfile in your repository. You can check the basic syntax of Jenkins pipeline definition.
- Prepare a workflow definition under the
.github/workflows
directory. You can check the official manual for more details. - In your GitHub Action workflow definition, you need to follow these steps when calling other actions in sequence:
- Use a ubuntu runner for the job.
jobs: job-name: runs-on: ubuntu-latest
- If you use jfr-container-action, you need to declare using the
ghcr.io/jenkinsci/jenkinsfile-runner:master
or any image extended it. If you use jfr-static-image-action, you can skip this step.
jobs: job-name: runs-on: ubuntu-latest container: image: ghcr.io/jenkinsci/jenkinsfile-runner:master
- Call the
actions/checkout@v2
to pull your codes into the runner. - If you use jfr-container-action, you need to call
Cr1t-GYM/jenkins-action-poc/jfr-container-action@master
and give necessary inputs. If you use jfr-static-image-action, you need to callCr1t-GYM/jenkins-action-poc/jfr-static-image-action@master
and give necessary inputs. See the examples for these two actions.
You can find the workflow definition in the .github/workflows/ci.yml.
This job pulls your repository first, and the workspace will be mapped to the container provided by
jfr-static-image-action
. By using the Cr1t-GYM/jenkins-action-poc/jfr-static-image-action@master
and
passing the necessary inputs, you can start the pipeline. Please note that most of the GitHub Actions will become
invalid because of the isolation between the host machine and the container. You still can use actions/checkout@v2
to prepare your sources.
jenkins-static-image-pipeline:
runs-on: ubuntu-latest
name: jenkins-static-image-pipeline-test
steps:
- uses: actions/checkout@v2
# jfr-static-image-action
- name: Jenkins pipeline with the static image
id: jenkins_pipeline_image
uses:
Cr1t-GYM/jenkins-action-poc/jfr-static-image-action@master
with:
command: run
jenkinsfile: Jenkinsfile
pluginstxt: plugins.txt
jcasc: jcasc.yml
This job pulls the ghcr.io/jenkinsci/jenkinsfile-runner:master
, pulls your repository, setup maven and run the Jenkins pipeline finally.
Please note that the declaration of ghcr.io/jenkinsci/jenkinsfile-runner:master
is necessary to use the jfr-container-action
action.
By using the Cr1t-GYM/jenkins-action-poc/jfr-container-action@master
and
passing the necessary inputs, you can start the pipeline.
jenkins-container-pipeline:
runs-on: ubuntu-latest
name: jenkins-prebuilt-container-test
container:
# prerequisite: extendance of ghcr.io/jenkinsci/jenkinsfile-runner:master
image: path/to/your_own_image
steps:
- uses: actions/checkout@v2
# jfr-container-action
- name: Jenkins pipeline in the container
id: jenkins_pipeline_container
uses:
Cr1t-GYM/jenkins-action-poc/jfr-container-action@master
with:
command: run
jenkinsfile: Jenkinsfile
pluginstxt: plugins.txt
jcasc: jcasc.yml
This case is realized by the combination of jenkins-setup, jenkins-plugin-installation-action and jenkinsfile-runner-action. It will download all the dependencies and run the pipeline at the host machine directly. Its advantage is that it can support Linux, macOS and Windows runners. Its main disadvantage is the possibility of suffering from a plugins.jenkins.io outage.
jenkins-runtime-pipeline:
# Run all the actions in the on demand VM.
needs: syntax-check
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: jenkins-runtime-pipeline-test
steps:
- uses: actions/checkout@v2
- name : Setup Jenkins
uses: Cr1t-GYM/jenkins-action-poc/jenkins-setup
- name: Jenkins plugins download
id: jenkins_plugins_download
uses: Cr1t-GYM/jenkins-action-poc/jenkins-plugin-installation-action
with:
pluginstxt: jenkins-setup/plugins.txt
- name: Run Jenkins pipeline
id: run_jenkins_pipeline
uses: Cr1t-GYM/jenkins-action-poc/jenkinsfile-runner-action
with:
command: run
jenkinsfile: Jenkinsfile
jcasc: jcasc.yml