-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build agent for Node.js 18 (master) #795
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,22 @@ jobs: | |
--build-arg nexusAuth=developer:s3cr3t \ | ||
. | ||
|
||
jenkins-agent-nodejs18-ubi8: | ||
name: Jenkins agent NodeJS 18 (UBI8) | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- | ||
name: Checkout repository | ||
uses: actions/[email protected] | ||
- | ||
name: Build docker image | ||
working-directory: common/jenkins-agents/nodejs18/docker | ||
run: | | ||
docker build --tag agent-nodejs18-test-ubi8 --file Dockerfile.ubi8 \ | ||
--build-arg nexusUrl=https://nexus.example.com \ | ||
--build-arg nexusAuth=developer:s3cr3t \ | ||
. | ||
|
||
jenkins-agent-python-ubi8: | ||
name: Jenkins agent Python (UBI8) | ||
runs-on: ubuntu-22.04 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
FROM opendevstackorg/ods-jenkins-agent-base-ubi8:latest | ||
|
||
# Labels consumed by Red Hat build service | ||
LABEL com.redhat.component="jenkins-agent-nodejs-18-rhel7-container" \ | ||
name="openshift4/jenkins-agent-nodejs-18-rhel7" \ | ||
architecture="x86_64" \ | ||
io.k8s.display-name="Jenkins Agent Nodejs" \ | ||
io.k8s.description="The jenkins agent nodejs image has the nodejs tools on top of the jenkins slave base image." \ | ||
io.openshift.tags="openshift,jenkins,agent,nodejs" \ | ||
maintainer="[email protected]" | ||
|
||
ARG nexusUrl | ||
ARG nexusAuth | ||
|
||
ENV NODEJS_VERSION=18 \ | ||
YARN_VERSION=1.22.18 \ | ||
NPM_CONFIG_PREFIX=$HOME/.npm-global \ | ||
PATH=$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \ | ||
LANG=en_US.UTF-8 \ | ||
LC_ALL=en_US.UTF-8 | ||
|
||
COPY contrib/bin/configure-agent /usr/local/bin/configure-agent | ||
|
||
# Generate machine ID | ||
RUN dbus-uuidgen > /etc/machine-id | ||
|
||
# Install NodeJS (https://rpm.nodesource.com/setup_${NODEJS_VERSION}.x does NOT work) | ||
RUN INSTALL_PKGS="nodejs nodejs-nodemon make gcc-c++" && \ | ||
yum module enable -y nodejs:${NODEJS_VERSION} && \ | ||
yum install -y --setopt=tsflags=nodocs --disableplugin=subscription-manager $INSTALL_PKGS && \ | ||
rpm -V $INSTALL_PKGS && \ | ||
yum clean all -y | ||
|
||
# Install Yarn | ||
# https://classic.yarnpkg.com/en/docs/install | ||
RUN curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION | ||
|
||
# Install Cypress dependencies | ||
# https://docs.cypress.io/guides/getting-started/installing-cypress.html#System-requirements | ||
COPY yum.repos.d/google-chrome.repo /etc/yum.repos.d/google-chrome.repo | ||
COPY yum.repos.d/centos8.repo /etc/yum.repos.d/centos8.repo | ||
RUN yum repolist \ | ||
&& yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-devel GConf2 nss libXScrnSaver alsa-lib \ | ||
&& yum install -y --enablerepo google-chrome google-chrome-stable \ | ||
&& yum clean all -y | ||
|
||
RUN npm config set registry=$nexusUrl/repository/npmjs/ && \ | ||
npm config set always-auth=true && \ | ||
npm config set _auth=$(echo -n $nexusAuth | base64) && \ | ||
npm config set [email protected] && \ | ||
npm config set ca=null && \ | ||
npm config set strict-ssl=false && \ | ||
yarn config set registry $nexusUrl/repository/npmjs/ -g && \ | ||
echo node version: $(node --version) && \ | ||
echo npm version: $(npm --version) && \ | ||
echo npx version: $(npx --version) && \ | ||
echo yarn version: $(yarn --version) | ||
|
||
RUN chown -R 1001:0 $HOME && \ | ||
chmod -R g+rw $HOME | ||
|
||
USER 1001 |
63 changes: 63 additions & 0 deletions
63
common/jenkins-agents/nodejs18/docker/contrib/bin/configure-agent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
# extract the different element of an url into a JSON structure | ||
parse_url() { | ||
# extract the protocol | ||
proto="$(echo $1 | cut -f1 -d: )" | ||
if [[ ! -z $proto ]] ; then | ||
# remove the protocol | ||
url="$(echo ${1/"$proto://"/})" | ||
# extract the user (if any) | ||
login="$(echo $url | grep @ | cut -d@ -f1)" | ||
username="$(echo $login | cut -d: -f1)" | ||
password="$(echo $login | cut -d: -f2)" | ||
# extract the host | ||
host_port="$(echo ${url/$login@/} | cut -d/ -f1) " | ||
host="$(echo $host_port | cut -f1 -d:) " | ||
|
||
# by request - try to extract the port | ||
port="$(echo $host_port | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')" | ||
# extract the uri (if any) | ||
resource="/$(echo $url | grep / | cut -d/ -f2-)" | ||
fi | ||
echo -n "{ \"uri\": \"$1\" , \"url\": \"$url\" , \"proto\": \"$proto\" , \"login\": \"$login\" ," | ||
echo " \"username\": \"$username\" , \"password\": \"$password\" , \"host\": \"$host\" , \"port\": \"$port\" }" | ||
} | ||
|
||
get_npm_proxy_config(){ | ||
local proto json | ||
proto=$1 | ||
json=$2 | ||
username=$( echo $json | jq -r .username) | ||
password=$( echo $json | jq -r .password) | ||
host=$( echo $json | jq -r .host) | ||
port=$( echo $json | jq -r .port) | ||
proxy_url="$host:$port" | ||
|
||
if [ -n "$username" -a -n "$password" ]; then | ||
proxy_url="$proto://$username:$password@$proxy_url" | ||
fi | ||
|
||
echo $proxy_url | ||
} | ||
|
||
|
||
if [ -n "$http_proxy" ]; then | ||
json=$( parse_url $http_proxy ) | ||
proxy=$(get_npm_proxy_config http "$json") | ||
npm -g config set proxy $proxy | ||
fi | ||
|
||
if [ -n "$https_proxy" ]; then | ||
json=$( parse_url $https_proxy ) | ||
proxy=$(get_npm_proxy_config https "$json") | ||
npm -g config set https_proxy $proxy | ||
fi | ||
|
||
if [ -n "$no_proxy" ]; then | ||
npm -g config set noproxy $no_proxy | ||
fi | ||
|
||
if [ -n "$NPM_MIRROR_URL" ]; then | ||
npm -g config set registry "$NPM_MIRROR_URL" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This will make scl collection binaries work out of box. | ||
unset BASH_ENV PROMPT_COMMAND ENV | ||
source scl_source enable rh-nodejs18 |
13 changes: 13 additions & 0 deletions
13
common/jenkins-agents/nodejs18/docker/yum.repos.d/centos8.repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[centos-baseos] | ||
name=CentOS-8-BaseOS | ||
baseurl=http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/ | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official | ||
|
||
[centos-appstream] | ||
name=CentOS-8-AppStream | ||
baseurl=http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/ | ||
enabled=1 | ||
gpgcheck=1 | ||
gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official |
6 changes: 6 additions & 0 deletions
6
common/jenkins-agents/nodejs18/docker/yum.repos.d/google-chrome.repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[google-chrome] | ||
name=google-chrome | ||
baseurl=https://dl.google.com/linux/chrome/rpm/stable/$basearch | ||
enabled=0 | ||
gpgcheck=1 | ||
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace ods | ||
selector app=jenkins-agent-nodejs18 | ||
param-file ../../../../../ods-configuration/ods-core.env | ||
ignore-unknown-parameters true | ||
bc,is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
apiVersion: template.openshift.io/v1 | ||
kind: Template | ||
metadata: | ||
name: jenkins-agent-nodejs18 | ||
parameters: | ||
- name: ODS_BITBUCKET_PROJECT | ||
description: Bitbucket project name. | ||
value: opendevstack | ||
- name: NEXUS_URL | ||
required: true | ||
- name: NEXUS_AUTH | ||
required: true | ||
- name: REPO_BASE | ||
required: true | ||
- name: ODS_IMAGE_TAG | ||
required: true | ||
value: latest | ||
- name: ODS_GIT_REF | ||
required: true | ||
- name: JENKINS_AGENT_DOCKERFILE_PATH | ||
value: Dockerfile.ubi8 | ||
description: Dockerfile variant to use | ||
objects: | ||
- apiVersion: v1 | ||
kind: BuildConfig | ||
metadata: | ||
name: jenkins-agent-nodejs18 | ||
labels: | ||
app: jenkins-agent-nodejs18 | ||
spec: | ||
failedBuildsHistoryLimit: 5 | ||
nodeSelector: null | ||
output: | ||
to: | ||
kind: ImageStreamTag | ||
name: jenkins-agent-nodejs18:${ODS_IMAGE_TAG} | ||
postCommit: {} | ||
resources: | ||
limits: | ||
cpu: "1" | ||
memory: "2Gi" | ||
requests: | ||
cpu: "200m" | ||
memory: "1Gi" | ||
runPolicy: Serial | ||
source: | ||
contextDir: common/jenkins-agents/nodejs18/docker | ||
git: | ||
ref: ${ODS_GIT_REF} | ||
uri: ${REPO_BASE}/${ODS_BITBUCKET_PROJECT}/ods-quickstarters.git | ||
sourceSecret: | ||
name: cd-user-token | ||
type: Git | ||
strategy: | ||
dockerStrategy: | ||
buildArgs: | ||
- name: nexusUrl | ||
value: ${NEXUS_URL} | ||
- name: nexusAuth | ||
value: ${NEXUS_AUTH} | ||
dockerfilePath: ${JENKINS_AGENT_DOCKERFILE_PATH} | ||
from: | ||
kind: ImageStreamTag | ||
name: jenkins-agent-base:${ODS_IMAGE_TAG} | ||
type: Docker | ||
successfulBuildsHistoryLimit: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: template.openshift.io/v1 | ||
kind: Template | ||
metadata: | ||
name: jenkins-agent-nodejs18 | ||
objects: | ||
- apiVersion: v1 | ||
kind: ImageStream | ||
metadata: | ||
name: jenkins-agent-nodejs18 | ||
labels: | ||
app: jenkins-agent-nodejs18 | ||
spec: | ||
lookupPolicy: | ||
local: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
= Node.js 18 - Jenkins agent | ||
|
||
== Introduction | ||
This agent is used to build Node.js-based projects, through `npm` or `yarn`. | ||
|
||
The image is built in the global `ods` project and is named `jenkins-agent-nodejs18`. | ||
It can be referenced in a `Jenkinsfile` with `ods/jenkins-agent-nodejs18`. | ||
|
||
IMPORTANT: Node.js version 18 reaches end-of-life in 2025-04-30. Support for this version will be removed in releases after this date. Please consider switching to newer versions of this agent as soon as they are available. | ||
|
||
== Features | ||
1. Nexus configuration | ||
2. HTTP proxy awareness | ||
3. Yarn & Cypress dependencies pre-installed | ||
|
||
== Known limitations | ||
n/a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it ubi8 instead of rhel7 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now as I look at this... the labels section definitely needs improvement. Regarding this topic there seems to be #506 for dealing with this on all agents. I would not fix it with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to fix it now.