Skip to content
Snippets Groups Projects
Commit 59bea6d1 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Merge branch 'malowe/main/5' into 'main'

iss. #5 - Added Jenkinsfile + needed make operations to support normal builds

See merge request !4
parents e7b8a885 3d7525ee
No related branches found
No related tags found
1 merge request!4iss. #5 - Added Jenkinsfile + needed make operations to support normal builds
Pipeline #4860 passed
@Library('common-shared') _
pipeline {
agent {
kubernetes {
label 'buildenv-agent'
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: buildcontainer
image: eclipsefdn/stack-build-agent:latest
imagePullPolicy: Always
command:
- cat
tty: true
resources:
requests:
cpu: "1"
memory: "4Gi"
limits:
cpu: "2"
memory: "4Gi"
env:
- name: "HOME"
value: "/home/jenkins"
- name: "MAVEN_OPTS"
value: "-Duser.home=/home/jenkins"
volumeMounts:
- name: m2-repo
mountPath: /home/jenkins/.m2/repository
- name: m2-secret-dir
mountPath: /home/jenkins/.m2/settings.xml
subPath: settings.xml
readOnly: true
- mountPath: "/home/jenkins/.m2/settings-security.xml"
name: "m2-secret-dir"
readOnly: true
subPath: "settings-security.xml"
- mountPath: "/home/jenkins/.mavenrc"
name: "m2-dir"
readOnly: true
subPath: ".mavenrc"
- mountPath: "/home/jenkins/.m2/wrapper"
name: "m2-wrapper"
readOnly: false
- mountPath: "/home/jenkins/.cache"
name: "yarn-cache"
readOnly: false
- name: jnlp
resources:
requests:
memory: "1024Mi"
cpu: "500m"
limits:
memory: "1024Mi"
cpu: "1000m"
volumes:
- name: "m2-dir"
configMap:
name: "m2-dir"
- name: m2-secret-dir
secret:
secretName: m2-secret-dir
- name: m2-repo
emptyDir: {}
- name: m2-wrapper
emptyDir: {}
- name: yarn-cache
emptyDir: {}
'''
}
}
environment {
APP_NAME = 'eclipsefdn-working-groups-api'
NAMESPACE = 'foundation-internal-webdev-apps'
IMAGE_NAME = 'eclipsefdn/eclipsefdn-working-groups-api'
CONTAINER_NAME = 'api'
ENVIRONMENT = sh(
script: """
printf "${env.BRANCH_NAME}"
""",
returnStdout: true
)
TAG_NAME = sh(
script: """
GIT_COMMIT_SHORT=\$(git rev-parse --short ${env.GIT_COMMIT})
if [ "${env.ENVIRONMENT}" = "" ]; then
printf \${GIT_COMMIT_SHORT}-${env.BUILD_NUMBER}
else
printf ${env.ENVIRONMENT}-\${GIT_COMMIT_SHORT}-${env.BUILD_NUMBER}
fi
""",
returnStdout: true
)
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 30, unit: 'MINUTES')
}
stages {
stage('Build project') {
steps {
container('buildcontainer') {
readTrusted 'Makefile'
readTrusted 'pom.xml'
sh 'make compile'
stash name: "target", includes: "target/**/*"
}
}
}
stage('Build docker image') {
agent {
label 'docker-build'
}
steps {
readTrusted 'src/main/docker/Dockerfile.jvm'
unstash 'target'
sh '''
docker build -f src/main/docker/Dockerfile.jvm --no-cache -t ${IMAGE_NAME}:${TAG_NAME} -t ${IMAGE_NAME}:latest .
'''
}
}
stage('Push docker image') {
agent {
label 'docker-build'
}
when {
anyOf {
environment name: 'ENVIRONMENT', value: 'production'
environment name: 'ENVIRONMENT', value: 'staging'
}
}
steps {
withDockerRegistry([credentialsId: '04264967-fea0-40c2-bf60-09af5aeba60f', url: 'https://index.docker.io/v1/']) {
sh '''
docker push ${IMAGE_NAME}:${TAG_NAME}
docker push ${IMAGE_NAME}:latest
'''
}
}
}
}
post {
always {
deleteDir() /* clean up workspace */
sendNotifications currentBuild
}
}
}
setup:;
test -f ".env" || cp config/.env.sample .env
test -f "./config/secret.properties" || cp config/secret.properties.sample config/secret.properties
\ No newline at end of file
test -f ".env" || cp config/.env.sample .env
test -f "./config/secret.properties" || cp config/secret.properties.sample config/secret.properties
clean:;
mvn clean
install-yarn:;
yarn install --frozen-lockfile --audit
generate-spec: install-yarn validate-spec;
yarn run generate-json-schema
validate-spec: install-yarn;
compile-java: generate-spec;
mvn compile package
compile-java-quick: generate-spec;
mvn compile package -Dmaven.test.skip=true
compile: clean compile-java;
compile-quick: clean compile-java-quick;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment