Skip to content

Commit

Permalink
Experimental commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmatej committed Jan 26, 2022
1 parent 41cc894 commit e0f6237
Show file tree
Hide file tree
Showing 29 changed files with 752 additions and 570 deletions.
292 changes: 195 additions & 97 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,27 @@
// without this, the agent could be using a pod created from a different descriptor
env.label = "glassfish-ci-pod-${UUID.randomUUID().toString()}"

// list of test ids
def jobs = [
// Docker image defined in this project in [glassfish]/etc/docker/Dockerfile
env.gfImage = "ee4jglassfish/ci:tini-jdk-11.0.10"

def jobs_cdi_jsp = [
"cdi_all",
"ql_gf_full_profile_all",
"ql_gf_web_profile_all",
"web_jsp",
]

def jobs_ejb = [
"ejb_group_1",
"ejb_group_2",
"ejb_group_3",
"ejb_group_embedded"
]

def jobs_quick_look = [
"verifyPhase",
"ql_gf_full_profile_all",
"ql_gf_web_profile_all",
]


def jobs_all = [
"cdi_all",
Expand All @@ -56,111 +65,120 @@ def jobs_all = [
"connector_group_4"
]

def parallelStagesMap = jobs.collectEntries {
["${it}": generateStage(it)]
def parallelStagesMap(jobs) {
return jobs.collectEntries {
["${it}": generateStage(it)]
}
}

def generateStage(job) {
return {
podTemplate(label: env.label) {
node(label) {
stage("${job}") {
container('glassfish-ci') {
// do the scm checkout
retry(10) {
sleep 60
checkout scm
}

// run the test
unstash 'build-bundles'

try {
retry(3) {
timeout(time: 2, unit: 'HOURS') {
sh """
export CLASSPATH=$WORKSPACE/glassfish6/javadb
./appserver/tests/gftest.sh run_test ${job}
"""
}
}
} finally {
// archive what we can...
archiveArtifacts artifacts: "${job}-results.tar.gz"
junit testResults: 'results/junitreports/*.xml', allowEmptyResults: false
}
}
}
if (job == 'verifyPhase') {
return generateMvnPodTemplate(job)
} else {
return generateAntPodTemplate(job)
}
}

def generateMvnPodTemplate(job) {
return {
podTemplate(
inheritFrom: "${env.label}",
containers: [
containerTemplate(
name: "glassfish-build",
image: "${env.gfImage}",
resourceRequestMemory: "7Gi",
resourceRequestCpu: "2650m"
)
]
) {
node(label) {
stage("${job}") {
container('glassfish-build') {
retry(5) {
sleep 1
checkout scm
}
timeout(time: 1, unit: 'HOURS') {
sh """
mvn clean install
"""
junit testResults: '**/*-reports/*.xml', allowEmptyResults: false
}
}
}
}
}
}
}

pipeline {

options {
// keep at most 50 builds
buildDiscarder(logRotator(numToKeepStr: '10'))

// preserve the stashes to allow re-running a test stage
preserveStashes()

// issue related to default 'implicit' checkout, disable it
skipDefaultCheckout()

// abort pipeline if previous stage is unstable
skipStagesAfterUnstable()

// show timestamps in logs
timestamps()

// global timeout, abort after 6 hours
timeout(time: 6, unit: 'HOURS')
def generateAntPodTemplate(job) {
return {
podTemplate(
inheritFrom: "${env.label}",
containers: [
containerTemplate(
name: "glassfish-build",
image: "${env.gfImage}",
resourceRequestMemory: "4Gi",
resourceRequestCpu: "2650m"
)
]
) {
node(label) {
stage("${job}") {
container('glassfish-build') {
retry(5) {
sleep 1
checkout scm
}
unstash 'build-bundles'
try {
timeout(time: 1, unit: 'HOURS') {
sh """
export CLASSPATH=$WORKSPACE/glassfish6/javadb
./appserver/tests/gftest.sh run_test ${job}
"""
}
} finally {
archiveArtifacts artifacts: "${job}-results.tar.gz"
junit testResults: 'results/junitreports/*.xml', allowEmptyResults: false
}
}
}
}
}
}
}

pipeline {

agent {
kubernetes {
label "${env.label}"
defaultContainer 'glassfish-ci'
yaml """
apiVersion: v1
kind: Pod
metadata:
spec:
volumes:
- name: "jenkins-home"
emptyDir: {}
- name: maven-repo-shared-storage
persistentVolumeClaim:
claimName: glassfish-maven-repo-storage
- name: settings-xml
secret:
secretName: m2-secret-dir
items:
- key: settings.xml
path: settings.xml
- name: settings-security-xml
secret:
secretName: m2-secret-dir
items:
- key: settings-security.xml
path: settings-security.xml
- name: maven-repo-local-storage
emptyDir: {}
containers:
- name: jnlp
image: jenkins/jnlp-slave:alpine
image: jenkins/inbound-agent:4.11-1-alpine-jdk11
imagePullPolicy: IfNotPresent
env:
- name: JAVA_TOOL_OPTIONS
value: -Xmx1G
value: "-Xmx768m -Xss768k"
resources:
# fixes random failure: minimum cpu usage per Pod is 200m, but request is 100m.
# affects performance on large repositories
limits:
memory: "1Gi"
cpu: "1"
- name: glassfish-ci
# Docker image defined in this project in [glassfish]/etc/docker/Dockerfile
image: ee4jglassfish/ci:tini-jdk-11.0.10
memory: "1200Mi"
cpu: "300m"
requests:
memory: "1200Mi"
cpu: "300m"
- name: glassfish-build
image: ${env.gfImage}
args:
- cat
tty: true
Expand All @@ -183,13 +201,38 @@ spec:
mountPath: "/home/jenkins/.m2/repository/org/glassfish/main"
env:
- name: "MAVEN_OPTS"
value: "-Duser.home=/home/jenkins"
value: "-Duser.home=/home/jenkins -Xmx2500m -Xss768k -XX:+UseStringDeduplication"
- name: "MVN_EXTRA"
value: "--batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
- name: JAVA_TOOL_OPTIONS
value: "-Xmx2g -Xss768k -XX:+UseStringDeduplication"
resources:
limits:
memory: "12Gi"
cpu: "8000m"
requests:
memory: "7Gi"
cpu: "3"
cpu: "4000m"
volumes:
- name: "jenkins-home"
emptyDir: {}
- name: maven-repo-shared-storage
persistentVolumeClaim:
claimName: glassfish-maven-repo-storage
- name: settings-xml
secret:
secretName: m2-secret-dir
items:
- key: settings.xml
path: settings.xml
- name: settings-security-xml
secret:
secretName: m2-secret-dir
items:
- key: settings-security.xml
path: settings-security.xml
- name: maven-repo-local-storage
emptyDir: {}
"""
}
}
Expand All @@ -204,21 +247,62 @@ spec:
PORT_HTTPS=8181
}

options {
buildDiscarder(logRotator(numToKeepStr: '10'))

// to allow re-running a test stage
preserveStashes()

// issue related to default 'implicit' checkout, disable it
skipDefaultCheckout()

// abort pipeline if previous stage is unstable
skipStagesAfterUnstable()

// show timestamps in logs
timestamps()

// global timeout, abort after 6 hours
timeout(time: 6, unit: 'HOURS')
}

stages {

// stage('quickinfo') {
// agent {
// kubernetes {
// label "${env.label}"
// }
// }
// steps {
// container('glassfish-build') {
// sh '''
// echo Maven version
// mvn -v
// echo Ant version
// ant -version
// echo User
// id
// echo Uname
// uname -a
// free -m
// df -h
// cat /proc/cpuinfo
// '''
// }
// }
// }

stage('build') {
agent {
kubernetes {
label "${env.label}"
}
}
steps {
container('glassfish-ci') {
container('glassfish-build') {
timeout(time: 1, unit: 'HOURS') {

// do the scm checkout
checkout scm

// do the build
sh '''
echo Maven version
mvn -v
Expand All @@ -229,24 +313,38 @@ spec:
echo Uname
uname -a
bash -xe ./gfbuild.sh build_re_dev
# Until we fix ANTLR in cmp-support-sqlstore, broken in parallel builds. Just -Pfast after the fix.
mvn clean install -Pfastest,staging -T4C
./gfbuild.sh archive_bundles
ls -la ./bundles
'''
archiveArtifacts artifacts: 'bundles/*.zip'
// junit testResults: 'test-results/build-unit-tests/results/junitreports/test_results_junit.xml'
stash includes: 'bundles/*', name: 'build-bundles'
}
}
}
}

stage('tests') {
stage('QuickLookTests') {
steps {
script {
parallel parallelStagesMap(jobs_quick_look)
}
}
}
stage('CDI_JSP_Tests') {
steps {
script {
parallel parallelStagesMap
parallel parallelStagesMap(jobs_cdi_jsp)
}
}
}
stage('EjbTests') {
steps {
script {
parallel parallelStagesMap(jobs_ejb)
}
}
}
}
}


Empty file.
Loading

0 comments on commit e0f6237

Please sign in to comment.