-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepared the new docker jenkins tester by using CASC & JenkinsBro tes…
…ts module (#101) * Prepared the new docker jenkins tester by using CASC & JenkinsBro tests module * Moved to the new circleci images
- Loading branch information
Showing
8 changed files
with
490 additions
and
12 deletions.
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 |
---|---|---|
|
@@ -24,7 +24,7 @@ workflows: | |
jobs: | ||
build: | ||
docker: | ||
- image: circleci/openjdk:8u222-jdk-stretch | ||
- image: circleci/openjdk:11-jdk | ||
|
||
working_directory: ~/repo | ||
|
||
|
@@ -82,30 +82,24 @@ jobs: | |
default: "" | ||
type: string | ||
docker: | ||
- image: circleci/openjdk:8u222-jdk-stretch | ||
- image: circleci/openjdk:11-jdk | ||
working_directory: ~/repo | ||
steps: | ||
- checkout | ||
|
||
- run: | ||
name: Get the jenkinsBro repo | ||
command: git clone https://github.com/rabits/jenkinsbro ~/jenkinsbro | ||
|
||
- setup_remote_docker | ||
# CircleCI cache now not free | ||
# docker_layer_caching: true | ||
|
||
- run: | ||
name: Build jenkins image | ||
command: ~/jenkinsbro/jenkinsbro_build.sh "<< parameters.jenkins_version >>" | ||
command: docker build -t jenkinsbro --build-arg "JENKINS_VERSION=$(.circleci/get_jenkins_version.sh << parameters.jenkins_version >>)" .circleci/jenkins | ||
no_output_timeout: 5m | ||
|
||
- run: | ||
name: Copy jenkinsbro configuration and tests | ||
name: Create jenkins_home container to store data | ||
command: | # CircleCI using remote docker server - so we can't just mount the folder... | ||
docker create -v /var/jenkins_home --name jenkins-home alpine /bin/true | ||
docker cp .circleci/jenkinsbro/config jenkins-home:/var/jenkins_home | ||
docker cp .circleci/jenkinsbro/jenkinsBro jenkins-home:/var/jenkins_home | ||
docker run --rm -it --volumes-from jenkins-home alpine chown -R 1000:1000 /var/jenkins_home | ||
- run: | ||
|
@@ -114,15 +108,16 @@ jobs: | |
docker run -e "MPL_VERSION=$(echo "${CIRCLE_BRANCH}" | sed 's|\(pull/[0-9]*\)|\1/merged|g')" | ||
-e "MPL_REFSPEC=$(echo "${CIRCLE_BRANCH}:remotes/origin/${CIRCLE_BRANCH}" | sed -e '/^pull/! s|\(.*\)|heads/\1|' -e 's|\(pull/[0-9]*\)|\1/merged|g')" | ||
-e "MPL_CLONE_URL=$(echo "${CIRCLE_REPOSITORY_URL}" | sed 's|[email protected]:|https://github.com/|')" | ||
--name jenkins --rm -it --volumes-from jenkins-home jenkinsbro-master | ||
-e "HTTP_PORT=8085" | ||
--name jenkins --rm -it --volumes-from jenkins-home jenkinsbro | ||
no_output_timeout: 5m | ||
|
||
- run: | ||
name: Collecting test reports | ||
when: always | ||
command: | | ||
mkdir -p results/artifacts results/reports | ||
docker cp jenkins-home:/var/jenkins_home/jenkinsBro/junit_report results/reports/junit | ||
docker cp jenkins-home:/var/jenkins_home/junit_report results/reports/junit | ||
docker rm jenkins-home | ||
- store_test_results: | ||
|
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,38 @@ | ||
#!/bin/sh | ||
# | ||
# Script to find of the lts/latest versions of jenkins | ||
# | ||
# Usage: | ||
# $ ./jenkinsbro_build.sh <VERSION> | ||
# | ||
# Parameters: | ||
# VERSION - allows to check the version to use, values: | ||
# * "2.176." - prefix of the jenkins version, will choose the latest available LTS 2.176.* | ||
# * "2.176.2" - exact version you want | ||
# * "lts" - latest stable version | ||
# * "latest" - just latest version | ||
# | ||
|
||
VAR_VERSION=$1 | ||
|
||
if [ -z "${VAR_VERSION}" ]; then | ||
echo Specify the version you need | ||
exit 1 | ||
fi | ||
|
||
ver_url=https://mirrors.jenkins.io/war | ||
ver="[0-9]" | ||
if [ "${VAR_VERSION}" = 'lts' ]; then | ||
ver_url=${ver_url}-stable | ||
elif [ "${VAR_VERSION}" != 'latest' ]; then | ||
ver=$(echo "${VAR_VERSION}" | tr -dc '0-9.') | ||
echo "Using specified version '${ver}'" 1>&2 | ||
fi | ||
|
||
jenkins_version=$(curl -s "${ver_url}/" | grep -oE 'href="'${ver}'[^/]*' | head -1 | tr -dc '0-9.') | ||
if [ "x$jenkins_version" = "x" ]; then | ||
echo "Unable to find version for: ${VAR_VERSION} '${jenkins_version}'" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
echo "${jenkins_version}" |
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,16 @@ | ||
# Dockerfile to put plugins and other vars to the image | ||
ARG JENKINS_VERSION | ||
|
||
FROM jenkins/jenkins:${JENKINS_VERSION}-jdk11 | ||
|
||
COPY --chown=jenkins:jenkins plugins.txt /usr/share/jenkins/ref/plugins.txt | ||
RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt | ||
|
||
ENV CASC_JENKINS_CONFIG=/usr/local/jenkins-casc \ | ||
CASC_GROOVY_TESTS_PATH=/usr/local/jenkins-tests \ | ||
JENKINS_HOSTNAME=localhost \ | ||
JAVA_OPTS="-Djenkins.install.runSetupWizard=false ${JAVA_OPTS:-}" | ||
|
||
COPY --chown=root:jenkins jenkins-casc.yml ${CASC_JENKINS_CONFIG}/ | ||
|
||
COPY --chown=root:jenkins tests ${CASC_GROOVY_TESTS_PATH}/ |
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,118 @@ | ||
--- | ||
# Jenkins server configuration | ||
|
||
jenkins: | ||
systemMessage: Jenkins Environment | ||
|
||
numExecutors: 1 # Should be 0 on prod envs | ||
|
||
agentProtocols: | ||
- JNLP4-connect | ||
- Ping | ||
|
||
# Proxy compatibility if using nginx | ||
#crumbIssuer: | ||
# standard: | ||
# excludeClientIPGromCrumb: true | ||
|
||
# Restricting agents in actions | ||
remotingSecurity: | ||
enabled: true | ||
|
||
# Set local access restrictions | ||
disableRememberMe: true | ||
|
||
# securityRealm: | ||
# local: | ||
# allowsSignup: false | ||
# users: | ||
# # There could be only one | ||
# - id: admin | ||
# password: admin | ||
# # To test the prod user access | ||
# - id: user | ||
# password: user | ||
# | ||
# authorizationStrategy: | ||
# globalMatrix: | ||
# permissions: | ||
# # In case needed to change the configs and see them in CASC export view | ||
# - EITHER:Overall/Administer:admin | ||
# | ||
# # Read only access for the user | ||
# - EITHER:Agent/ExtendedRead:authenticated | ||
# - EITHER:Credentials/View:authenticated | ||
# - EITHER:Job/Build:authenticated | ||
# - EITHER:Job/Cancel:authenticated | ||
# - EITHER:Job/Configure:authenticated | ||
# - EITHER:Job/Create:authenticated | ||
# - EITHER:Job/Delete:authenticated | ||
# - EITHER:Job/Move:authenticated | ||
# - EITHER:Job/Read:authenticated | ||
# - EITHER:Overall/Read:authenticated | ||
# - EITHER:Overall/SystemRead:authenticated | ||
# - EITHER:Run/Delete:authenticated | ||
# - EITHER:Run/Update:authenticated | ||
# - EITHER:View/Configure:authenticated | ||
# - EITHER:View/Create:authenticated | ||
# - EITHER:View/Delete:authenticated | ||
# - EITHER:View/Read:authenticated | ||
|
||
unclassified: | ||
location: | ||
adminAddress: admin@localhost | ||
url: http://${JENKINS_HOSTNAME}:${HTTP_PORT}/ # Actually better to use https | ||
|
||
audit-trail: | ||
logBuildCause: true | ||
pattern: ".*/(?:configSubmit|doDelete|postBuildResult|enable|disable|cancelQueue|stop|toggleLogKeep|doWipeOutWorkspace|createItem|createView|toggleOffline|cancelQuietDown|quietDown|restart|exit|safeExit)/?.*" | ||
loggers: | ||
- logFile: | ||
count: 30 | ||
limit: 1000 | ||
log: /var/jenkins_home/logs/audit.log | ||
logSeparator: " " | ||
|
||
globalLibraries: | ||
libraries: | ||
- name: mpl | ||
defaultVersion: ${MPL_VERSION} | ||
retriever: | ||
modernSCM: | ||
scm: | ||
git: | ||
remote: ${MPL_CLONE_URL} | ||
traits: | ||
- cloneOptionTrait: | ||
extension: | ||
honorRefspec: true | ||
noTags: false | ||
reference: ${MPL_REFSPEC} | ||
shallow: false | ||
|
||
tool: | ||
git: | ||
installations: | ||
- name: Environment git client | ||
home: git | ||
maven: | ||
installations: | ||
- name: Maven 3 | ||
properties: | ||
- installSource: | ||
installers: | ||
- maven: | ||
id: '3.6.3' | ||
|
||
|
||
# Run script with tests | ||
groovy: | ||
- script: | | ||
import jenkins.model.Jenkins | ||
println('Running JenkinsBro test framework...') | ||
GroovyShell shell = new GroovyShell(Jenkins.instance.getPluginManager().uberClassLoader, binding) | ||
shell.evaluate(new File('/usr/local/jenkins-tests/tests.groovy')) | ||
println('JenkinsBro test framework is running...') |
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,10 @@ | ||
ansicolor | ||
build-timeout | ||
git | ||
jobConfigHistory | ||
timestamper | ||
workflow-aggregator | ||
configuration-as-code | ||
configuration-as-code-groovy | ||
matrix-auth | ||
audit-trail |
Oops, something went wrong.