Skip to content
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

Update jenkins-agent-nodejs to nodeJS 16 #764

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,38 @@ jobs:
--build-arg nexusAuth=developer:s3cr3t \
.

jenkins-agent-nodejs16-centos7:
name: Jenkins agent NodeJS 16 (CENTOS7)
runs-on: ubuntu-18.04
steps:
-
name: Checkout repository
uses: actions/[email protected]
-
name: Build docker image
working-directory: common/jenkins-agents/nodejs16/docker
run: |
docker build --tag agent-nodejs16-test-centos7 --file Dockerfile.centos7 \
--build-arg nexusUrl=https://nexus.example.com \
--build-arg nexusAuth=developer:s3cr3t \
.

jenkins-agent-nodejs16-ubi8:
name: Jenkins agent NodeJS 16 (UBI8)
runs-on: ubuntu-18.04
steps:
-
name: Checkout repository
uses: actions/[email protected]
-
name: Build docker image
working-directory: common/jenkins-agents/nodejs16/docker
run: |
docker build --tag agent-nodejs16-test-ubi8 --file Dockerfile.ubi8 \
--build-arg nexusUrl=https://nexus.example.com \
--build-arg nexusAuth=developer:s3cr3t \
.

jenkins-agent-python-centos7:
name: Jenkins agent Python (CENTOS7)
runs-on: ubuntu-18.04
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Use Java 17 (LTS) in maven jenkins-agent and spring boot qs ([#651](https://github.com/opendevstack/ods-quickstarters/pull/651))
- ODS AMI build fails due to failing jacoco report generation in springboot quickstarter ([#700](https://github.com/opendevstack/ods-quickstarters/pull/700))
- terraform agent sops/age added ([#730](https://github.com/opendevstack/ods-quickstarters/issues/730))
- add Node.js 16 builder agent ([#763](https://github.com/opendevstack/ods-quickstarters/issues/763)

### Fixed

Expand Down
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ ODS_NAMESPACE := $(shell grep ODS_NAMESPACE $(CURDIR)/../ods-configuration/ods-c

# JENKINS AGENT
## Install or update Jenkins agent resources.
install-jenkins-agent: install-jenkins-agent-golang install-jenkins-agent-maven install-jenkins-agent-nodejs12 install-jenkins-agent-python install-jenkins-agent-scala install-jenkins-agent-terraform
install-jenkins-agent: install-jenkins-agent-golang install-jenkins-agent-maven install-jenkins-agent-nodejs install-jenkins-agent-python install-jenkins-agent-scala install-jenkins-agent-terraform
.PHONY: install-jenkins-agent

## Update OpenShift resources related Jenkins agent resources.
apply-jenkins-agent-build: apply-jenkins-agent-golang-build apply-jenkins-agent-maven-build apply-jenkins-agent-nodejs12-build apply-jenkins-agent-python-build apply-jenkins-agent-scala-build apply-jenkins-agent-terraform-build
apply-jenkins-agent-build: apply-jenkins-agent-golang-build apply-jenkins-agent-maven-build apply-jenkins-agent-nodejs12-build apply-jenkins-agent-nodejs16-build apply-jenkins-agent-python-build apply-jenkins-agent-scala-build apply-jenkins-agent-terraform-build
.PHONY: apply-jenkins-agent-build

## Start builds of Jenkins agents.
start-jenkins-agent-build: start-jenkins-agent-golang-build start-jenkins-agent-maven-build start-jenkins-agent-nodejs12-build start-jenkins-agent-python-build start-jenkins-agent-scala-build start-jenkins-agent-terraform-build
start-jenkins-agent-build: start-jenkins-agent-golang-build start-jenkins-agent-maven-build start-jenkins-agent-nodejs12-build start-jenkins-agent-nodejs16-build start-jenkins-agent-python-build start-jenkins-agent-scala-build start-jenkins-agent-terraform-build
.PHONY: start-jenkins-agent-build


Expand Down Expand Up @@ -54,19 +54,26 @@ start-jenkins-agent-maven-build:

# JENKINS AGENT NODEJS
## Install or update Jenkins Node agent resources.
install-jenkins-agent-nodejs12: apply-jenkins-agent-nodejs12-build start-jenkins-agent-nodejs12-build
.PHONY: install-jenkins-agent-nodejs12
install-jenkins-agent-nodejs: apply-jenkins-agent-nodejs12-build apply-jenkins-agent-nodejs16-build start-jenkins-agent-nodejs12-build start-jenkins-agent-nodejs16-build
.PHONY: install-jenkins-agent-nodejs

## Update OpenShift resources related to Jenkins Node agent image.
apply-jenkins-agent-nodejs12-build:
cd common/jenkins-agents/nodejs12/ocp-config && tailor apply --namespace $(ODS_NAMESPACE)
.PHONY: apply-jenkins-agent-nodejs12-build

## Start build of BuildConfig "jenkins-agent-nodejs12".
apply-jenkins-agent-nodejs16-build:
cd common/jenkins-agents/nodejs16/ocp-config && tailor apply --namespace $(ODS_NAMESPACE)
.PHONY: apply-jenkins-agent-nodejs16-build

## Start build of BuildConfig "jenkins-agent-nodejs*".
start-jenkins-agent-nodejs12-build:
oc -n $(ODS_NAMESPACE) start-build jenkins-agent-nodejs12 --follow
.PHONY: start-jenkins-agent-nodejs12-build

start-jenkins-agent-nodejs16-build:
oc -n $(ODS_NAMESPACE) start-build jenkins-agent-nodejs16 --follow
.PHONY: start-jenkins-agent-nodejs16-build

# JENKINS AGENT PYTHON
## Install or update Jenkins Python agent resources.
Expand Down
1 change: 1 addition & 0 deletions common/jenkins-agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The ODS [jenkins shared library](https://github.com/opendevstack/ods-jenkins-sha
1. [GoLang](golang)
2. [Maven / Gradle](maven)
3. [Node.js 12](nodejs12)
4. [Node.js 16](nodejs16)
5. [Python](python)
6. [Scala & SBT](scala)
7. [Terraform](terraform)
Expand Down
87 changes: 87 additions & 0 deletions common/jenkins-agents/nodejs16/docker/Dockerfile.centos7
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
FROM opendevstackorg/ods-jenkins-agent-base-centos7:latest

# Labels consumed by Red Hat build service
LABEL com.redhat.component="jenkins-agent-nodejs-rhel7-docker" \
name="openshift3/jenkins-agent-nodejs-rhel7" \
version="3.6" \
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 agent base image." \
io.openshift.tags="openshift,jenkins,agent,nodejs"

ARG nexusUrl
ARG nexusAuth

ENV NODEJS_VERSION=16 \
NPM_CONFIG_PREFIX=$HOME/.npm-global \
PATH=$HOME/node_modules/.bin/:$HOME/.npm-global/bin/:$PATH \
BASH_ENV=/usr/local/bin/scl_enable \
ENV=/usr/local/bin/scl_enable \
PROMPT_COMMAND=". /usr/local/bin/scl_enable" \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
CHROME_VERSION=99.0.4844.74

# install google-chrome (for angular)
RUN yum-config-manager --enable rhel-7-server-extras-rpms && \
yum-config-manager --enable rhel-7-server-optional-rpms

ADD https://dl.google.com/linux/chrome/rpm/stable/x86_64/google-chrome-stable-${CHROME_VERSION}-1.x86_64.rpm /root/google-chrome.rpm
RUN yum -y install redhat-lsb libXScrnSaver
RUN yum -y install /root/google-chrome.rpm && \
ln -s /usr/lib64/libOSMesa.so.8 /opt/google/chrome/libosmesa.so && \
yum clean all && \
dbus-uuidgen > /etc/machine-id && \
rm /root/google-chrome.rpm

# Install cypress dependencies
# Please note: xorg-x11-server-Xvfb is not available on RHEL via yum anymore, so "RUN yum install -y xorg-x11-server-Xvfb" won't work.
# Therefore this Dockerfile uses the version from CentOS instead.
ADD http://mirror.centos.org/centos/7/os/x86_64/Packages/xorg-x11-server-Xvfb-1.20.4-10.el7.x86_64.rpm /root/xorg-x11-server-Xvfb.x86_64.rpm
RUN yum install -y /root/xorg-x11-server-Xvfb.x86_64.rpm && \
yum install -y gtk2-2.24* && \
yum install -y libXtst* && \
yum install -y libXScrnSaver* && \
yum install -y GConf2* && \
yum install -y alsa-lib* && \
yum install -y nss-devel libnotify-devel gnu-free-sans-fonts && \
yum clean all -y
# libXScrnSaver* provides libXss
# GConf2* provides libgconf-2
# alsa-lib* provides libasound


# Install NodeJS + Yarn + Angular CLI
# installation details see: https://www.softwarecollections.org/en/
# and the base image relies on scl_enable
COPY contrib/bin/scl_enable /usr/local/bin/scl_enable

# Install NodeJS
# https://github.com/nodesource/distributions#installation-instructions-1
RUN curl --silent --location https://rpm.nodesource.com/setup_${NODEJS_VERSION}.x | bash - && \
yum install -y nodejs && \
yum install -y gcc-c++ make

# Install Yarn
# https://classic.yarnpkg.com/en/docs/install/#centos-stable
RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
yum install -y yarn && \
yum clean all -y

# Install Python 3 (because node-gyp, an ionic dependency, uses it) and set it as default
RUN yum install -y python3 py3-pip && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
python -V

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 && \
npm --version

RUN chgrp -R 0 $HOME && \
chmod -R g=u $HOME
USER 1001
62 changes: 62 additions & 0 deletions common/jenkins-agents/nodejs16/docker/Dockerfile.ubi8
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-16-rhel7-container" \
name="openshift4/jenkins-agent-nodejs-16-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=16 \
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 common/jenkins-agents/nodejs16/docker/contrib/bin/configure-agent
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
3 changes: 3 additions & 0 deletions common/jenkins-agents/nodejs16/docker/contrib/bin/scl_enable
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-nodejs16
13 changes: 13 additions & 0 deletions common/jenkins-agents/nodejs16/docker/yum.repos.d/centos8.repo
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
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
5 changes: 5 additions & 0 deletions common/jenkins-agents/nodejs16/ocp-config/Tailorfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace ods
selector app=jenkins-agent-nodejs16
param-file ../../../../../ods-configuration/ods-core.env
ignore-unknown-parameters true
bc,is
Loading