Skip to content

Commit 25676e1

Browse files
authored
Merge pull request #771 from marklogic/feature/22604-jenkinsfile-docker
MLE-22604 Converting Jenkinsfile to use Docker
2 parents 3d521a9 + 1b74cd6 commit 25676e1

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MARKLOGIC_IMAGE=ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi-rootless:latest-12
2+
MARKLOGIC_LOGS_PATH=./docker/marklogic/logs

Jenkinsfile

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,54 @@
11
@Library('shared-libraries') _
2-
pipeline{
2+
3+
def setupDockerMarkLogic(String image) {
4+
sh label:'mlsetup', script: '''#!/bin/bash
5+
echo "Removing any running MarkLogic server and clean up MarkLogic data directory"
6+
sudo /usr/local/sbin/mladmin remove
7+
sudo /usr/local/sbin/mladmin cleandata
8+
cd ml-gradle
9+
docker-compose down -v || true
10+
docker volume prune -f
11+
echo "Using image: "'''+image+'''
12+
docker pull '''+image+'''
13+
MARKLOGIC_IMAGE='''+image+''' MARKLOGIC_LOGS_PATH=/tmp/marklogic/logs docker compose up -d --build
14+
echo "Waiting for MarkLogic server to initialize."
15+
sleep 60s
16+
'''
17+
}
18+
19+
def tearDownDocker() {
20+
sh label:'tearDownDocker', script: '''#!/bin/bash
21+
cd ml-gradle
22+
docker compose down -v || true
23+
docker volume prune -f
24+
sudo rm -rf /tmp/marklogic/logs
25+
'''
26+
}
27+
28+
pipeline {
329
agent {label 'devExpLinuxPool'}
30+
431
options {
532
checkoutToSubdirectory 'ml-gradle'
6-
buildDiscarder logRotator(artifactDaysToKeepStr: '7', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '')
33+
buildDiscarder logRotator(artifactDaysToKeepStr: '7', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: '5')
734
}
8-
environment{
35+
36+
environment {
937
JAVA_HOME_DIR="/home/builder/java/jdk-17.0.2"
1038
GRADLE_DIR =".gradle"
1139
DMC_USER = credentials('MLBUILD_USER')
1240
DMC_PASSWORD = credentials('MLBUILD_PASSWORD')
1341
}
14-
stages{
15-
stage('tests'){
16-
steps{
17-
copyRPM 'Release','11.3.0'
18-
setUpML '$WORKSPACE/xdmp/src/Mark*.rpm'
42+
43+
stages {
44+
45+
stage('tests') {
46+
steps {
47+
cleanupDocker()
48+
setupDockerMarkLogic("ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi-rootless:latest-12")
1949
sh label:'test', script: '''#!/bin/bash
50+
# 'set -e' causes the script to fail if any command fails.
51+
set -e
2052
export JAVA_HOME=$JAVA_HOME_DIR
2153
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
2254
export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
@@ -31,7 +63,14 @@ pipeline{
3163
'''
3264
junit '**/build/**/*.xml'
3365
}
66+
post {
67+
always {
68+
tearDownDocker()
69+
cleanupDocker()
70+
}
71+
}
3472
}
73+
3574
stage('publish'){
3675
when {
3776
branch 'dev'

docker-compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name: docker-tests-ml-gradle
33
services:
44

55
marklogic:
6-
image: "progressofficial/marklogic-db:latest"
6+
image: "${MARKLOGIC_IMAGE}"
77
platform: linux/amd64
88
environment:
99
- MARKLOGIC_INIT=true
1010
- MARKLOGIC_ADMIN_USERNAME=admin
1111
- MARKLOGIC_ADMIN_PASSWORD=admin
1212
volumes:
13-
- ./docker/marklogic/logs:/var/opt/MarkLogic/Logs
13+
- ${MARKLOGIC_LOGS_PATH}:/var/opt/MarkLogic/Logs
1414
ports:
1515
- "8000-8008:8000-8008"
1616
- "8028:8028"

0 commit comments

Comments
 (0)