Skip to content

Latest commit

 

History

History
130 lines (95 loc) · 3.58 KB

jenkins-configuration.adoc

File metadata and controls

130 lines (95 loc) · 3.58 KB

Jenkins configuration

Prerequisite: rhel7-installation.adoc

Jenkins CLI - plugins

Plugins installation

wget http://SERVER:PORT/jnlpJars/jenkins-cli.jar
alias jenkins-cli='java -jar ~/Downloads/jenkins-cli.jar -s http://SERVER:PORT/ -auth USER:TOKEN'

jenkins-cli help
jenkins-cli install-plugin maven-plugin blueocean pipeline-maven description-setter ansicolor
jenkins-cli install-plugin job-dsl pipeline-utility-steps pipeline-model-definition parameterized-trigger
jenkins-cli safe-restart
jenkins-cli list-plugins

List plugins

Execute jenkins-cli groovy = < plugins.groovy > plugins.txt to list installed plugins.

link:plugins.groovy[role=include]

Update plugins

UPDATE_LIST=$( jenkins-cli list-plugins 2>/dev/null | grep -e ')$' | cut -d" " -f1 );
if [ ! -z "${UPDATE_LIST}" ]; then
    echo Updating Jenkins Plugins: ${UPDATE_LIST};
    jenkins-cli install-plugin ${UPDATE_LIST}
fi
jenkins-cli safe-restart

SDKMan

Using https://sdkman.io/ to manage Java and Maven installations.

SDKMan installation

yum install -y unzip zip

su - jenkins -s/bin/bash
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"

sed -i -e 's/sdkman_auto_answer=false/sdkman_auto_answer=true/g' ~/.sdkman/etc/config

Tools installation

Switch to jenkins user via su - jenkins -s/bin/bash

sdk list maven
sdk list java

sdk install java 15.ea.2-open
sdk install java 14.ea.28-open
sdk install java 13.0.1-open
sdk install java 12.0.2-open
sdk install java 11.0.5-open

sdk install java 19.2.1-grl
sdk install java 19.3.0.2.r8-grl

sdk use java 19.2.1-grl
gu install native-image
sdk use java 19.3.0.2.r8-grl
gu install native-image

sdk install maven 3.6.0
sdk install maven 3.5.4
sdk install maven 3.6.3
sdk default maven 3.6.3

ls /var/lib/jenkins/.sdkman/candidates/
ls /var/lib/jenkins/.sdkman/candidates/*/

You can add above commands into Jenkins job or run them manually on the server. With Jenkins job way you may encounter unexpected issues if SDKMan was not executed yet.

Jenkins tools setup

Configuration via groovy scripts and Jenkins API.

Alternative way for managing Jenkins is via using https://github.com/jenkinsci/configuration-as-code-plugin effort. This is still quite young effort and using Jenkins API provides good flexibility.

JDK setup

Execute jenkins-cli groovy = < configure-jdks.groovy to configure JDK installations for Jenkins.

link:configure-jdks.groovy[role=include]

It’s suggested to open http://SERVER:PORT/configureTools/, review configured tools and press Save button. I noticed unexpected behavior after restart where JDK setup was not correctly persisted. On the other hand Maven setup is working well.

Maven setup

Execute jenkins-cli groovy = < configure-maven.groovy to configure Maven installations for Jenkins.

link:configure-maven.groovy[role=include]

Pipelines troubles

Pipeline gets killed

You might see JENKINS-48300: if on an extremely laggy filesystem, consider -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.HEARTBEAT_CHECK_INTERVAL=86400) in the log of the pipeline.

Message mentions slow disk but this also happens when the system is under heavy load - e.g. native-image execution.

In RHEL7 case HEARTBEAT_CHECK_INTERVAL can be set in /etc/sysconfig/jenkins ,search for JENKINS_JAVA_OPTIONS.