Skip to content

SimonGolms/ods-jenkins-agent-nodejs

Repository files navigation

OpenDevStack 4.x - Jenkins Agent Node.js

Version License: Apache-2.0 Maintenance Conventional Commits semantic-release: angular OpenDevStack OpenShift Container Platform Jenkins Agent

Introduction

This Jenkins agent is used to build Node.js based projects, thru npm and npx. It use ods/jenkins-agent-base:4.x as base image in an OpenShift 4 Instance with OpenDevStack 4.x.

Features

  1. Node.js v16.x | v18.x | lts | current
  2. npm v8.x | latest
  3. (optional) Nexus configuration

Usage

The image is built in your active OpenShift Project and is named jenkins-agent-nodejs-<VERSION>. It can be referenced in a Jenkinsfile with <PROJECT>/jenkins-agent-nodejs-<VERSION>.

// Jenkinsfile
odsComponentPipeline(
-  imageStreamTag: 'ods/jenkins-agent-nodejs12:4.x',
+  imageStreamTag: "foo-cd/jenkins-agent-nodejs-16:latest",
)
// Jenkinsfile with custom agent resources
odsComponentPipeline(
-  imageStreamTag: 'ods/jenkins-agent-nodejs12:4.x',
+  podContainers: [
+    containerTemplate(
+      alwaysPullImage: true,
+      args: '${computer.jnlpmac} ${computer.name}',
+      image: "image-registry.openshift-image-registry.svc:5000/foo-cd/jenkins-agent-nodejs-16:latest",
+      name: 'jnlp',
+      resourceLimitCpu: '3',
+      resourceLimitMemory: '8Gi',
+      resourceRequestCpu: '10m',
+      resourceRequestMemory: '4Gi',
+      workingDir: '/tmp'
+    )
+  ],
)

Provisioning

CLI

# v16.x
oc process -f https://raw.githubusercontent.com/SimonGolms/ods-jenkins-agent-nodejs/main/jenkins-agent-nodejs-16-template.yaml | oc create -f -
# v18.x
oc process -f https://raw.githubusercontent.com/SimonGolms/ods-jenkins-agent-nodejs/main/jenkins-agent-nodejs-18-template.yaml | oc create -f -
# lts
oc process -f https://raw.githubusercontent.com/SimonGolms/ods-jenkins-agent-nodejs/main/jenkins-agent-nodejs-lts-template.yaml | oc create -f -
# current
oc process -f https://raw.githubusercontent.com/SimonGolms/ods-jenkins-agent-nodejs/main/jenkins-agent-nodejs-current-template.yaml | oc create -f -
# with nexus configuration
oc process -f https://raw.githubusercontent.com/SimonGolms/ods-jenkins-agent-nodejs/main/jenkins-agent-nodejs-<VERSION>-template.yaml \
  -p NEXUS_URL=https://NEXUS_INSTANCE \
  -p NEXUS_AUTH=USERNAME:PASSWORD \
  | oc create -f -

Manual

Import jenkins-agent-nodejs-<VERSION>-template.yaml into your OpenShift instance and process the template. Replace your project name if necessary (e.g. foo-cd -> bar-cd).

Go to https://OPENSHIFT_INSTANCE/catalog/ns/PROJECT?catalogType=Template&keyword=jenkins and click on Jenkins Agent Node.js (<VERSION>) -> Instantiate Template -> Create

Update

CLI

In case of a new version of Node.js or npm is released, run the following command to create a new image with updated versions:

# v16.x
oc start-build jenkins-agent-nodejs-16 --follow
# v18.x
oc start-build jenkins-agent-nodejs-18 --follow
# lts
oc start-build jenkins-agent-nodejs-lts --follow
# current
oc start-build jenkins-agent-nodejs-current --follow

In case it is necessary and you need a specific npm version, you can provide it via --build-arg:

# with specific npm version
oc start-build jenkins-agent-nodejs-<VERSION> --build-arg NPM_VERSION=8.5.3 --follow

Manual

Go to your Build Configs https://OPENSHIFT_INSTANCE/k8s/ns/PROJECT/buildconfigs/jenkins-agent-nodejs-VERSION and click on Actions -> Start Build.

Abandon

CLI

# v16.x
oc delete all --selector app=jenkins-agent-nodejs-16
# v18.x
oc delete all --selector app=jenkins-agent-nodejs-18
# lts
oc delete all --selector app=jenkins-agent-nodejs-lts
# current
oc delete all --selector app=jenkins-agent-nodejs-current
# v16.x & v18.x & lts & current
oc delete all --selector part-of=jenkins-agent-nodejs

(Optional) Template from workspace catalog

oc delete template jenkins-agent-nodejs-<VERSION>

Manual

  1. Go to your Image Streams https://OPENSHIFT_INSTANCE/k8s/ns/PROJECT/imagestreams/jenkins-agent-nodejs-VERSION and click on Actions -> Delete ImageStream.
  2. Go to your Build Configs https://OPENSHIFT_INSTANCE/k8s/ns/PROJECT/buildconfigs/jenkins-agent-nodejs-VERSION and click on Actions -> Delete BuildConfig.

Author

Simon Golms

Show your support

Give a ⭐️ if this project helped you!

License

Copyright © 2022 Simon Golms.
This project is Apache-2.0 licensed.

Resources