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

Update CI to use Jenkins file rather than gitlab CI file


Updated job builds to ensure stability, and if the branch is master,
then it builds and deploys the jars to repo.eclipse.org

Signed-off-by: Martin Lowe's avatarMartin Lowe <martin.lowe@eclipse-foundation.org>
parent fb078889
No related branches found
No related tags found
1 merge request!2Updates for docs + initial build script
# Build JAVA applications using Apache Maven (http://maven.apache.org)
# For docker image tags see https://hub.docker.com/_/maven/
#
# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
# This template will build and test your projects
# * Caches downloaded dependencies and plugins between invocation.
# * Verify but don't deploy merge requests.
# * Deploy built artifacts from master branch only.
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
# This template uses jdk8 for verifying and deploying images
image: maven:3.3.9-jdk-8
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository
# For merge requests do not `deploy` but only run `verify`.
# See https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
.verify: &verify
stage: test
script:
- 'mvn $MAVEN_CLI_OPTS verify -Dconfig.secret.path=config/sample.secret.properties'
except:
- master
# Verify merge requests using JDK8
verify:jdk8:
<<: *verify
# To deploy packages from CI, create a ci_settings.xml file
# For deploying packages to GitLab's Maven Repository: See https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#creating-maven-packages-with-gitlab-cicd for more details.
# Please note: The GitLab Maven Repository is currently only available in GitLab Premium / Ultimate.
# For `master` branch run `mvn deploy` automatically.
deploy:jdk8:
stage: deploy
script:
- if [ ! -f ci_settings.xml ];
then echo "CI settings missing\! If deploying to GitLab Maven Repository, please see https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#creating-maven-packages-with-gitlab-cicd for instructions.";
fi
- 'mvn $MAVEN_CLI_OPTS deploy -s ci_settings.xml'
only:
- master
@Library('common-shared') _
pipeline {
agent {
kubernetes {
label 'buildpack-agent'
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: buildpack
image: buildpack-deps:stable
command:
- cat
tty: true
resources:
limits:
memory: "2Gi"
cpu: "1"
requests:
memory: "2Gi"
cpu: "1"
volumeMounts:
- name: tmp
mountPath: /tmp
- name: jnlp
resources:
limits:
memory: "2Gi"
cpu: "1"
requests:
memory: "2Gi"
cpu: "1"
volumeMounts:
- name: mvnw
mountPath: /home/jenkins/.m2/wrapper
readOnly: false
- name: m2-repo
mountPath: /home/jenkins/.m2/repository
- name: settings-xml
mountPath: /home/jenkins/.m2/settings.xml
subPath: settings.xml
readOnly: true
- name: tmp
mountPath: /tmp
volumes:
- name: mvnw
emptyDir: {}
- name: m2-repo
emptyDir: {}
- name: tmp
emptyDir: {}
- name: settings-xml
secret:
secretName: m2-secret-dir
items:
- key: settings.xml
path: settings.xml
'''
}
}
environment {
APP_NAME = 'geoip-rest-api'
NAMESPACE = 'foundation-internal-webdev-apps'
IMAGE_NAME = 'eclipsefdn/geoip-rest-api'
CONTAINER_NAME = 'app'
ENVIRONMENT = sh(
script: """
if [ "${env.BRANCH_NAME}" = "master" ]; then
printf "production"
else
printf "${env.BRANCH_NAME}"
fi
""",
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'))
}
triggers {
// build once a week to keep up with parents images updates
cron('H H * * H')
}
stages {
stage('Build Java code') {
steps {
sh './mvnw -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode package'
stash includes: 'target/', name: 'target'
}
}
stage('Push package image to Nexus') {
agent {
label 'docker-build'
}
when {
anyOf {
environment name: 'ENVIRONMENT', value: 'production'
}
}
steps {
sh '''
sh './mvnw -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --batch-mode clean deploy'
'''
}
}
}
post {
always {
deleteDir() /* clean up workspace */
sendNotifications currentBuild
}
}
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.eclipsefoundation</groupId> <groupId>org.eclipsefoundation</groupId>
<artifactId>quarkus-commons</artifactId> <artifactId>quarkus-commons</artifactId>
<name>Java SDK Commons</name> <name>Java SDK Commons</name>
<version>0.1-BETA</version> <version>0.1-BETA</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<properties> <properties>
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
<maven.compiler.parameters>true</maven.compiler.parameters> <maven.compiler.parameters>true</maven.compiler.parameters>
<compiler-plugin.version>3.8.1</compiler-plugin.version> <compiler-plugin.version>3.8.1</compiler-plugin.version>
<sonar.sources>src/main</sonar.sources> <sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests> <sonar.tests>src/test</sonar.tests>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin> <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
...@@ -23,6 +23,13 @@ ...@@ -23,6 +23,13 @@
<sonar.jacoco.reportPaths>${project.build.directory}/jacoco-report</sonar.jacoco.reportPaths> <sonar.jacoco.reportPaths>${project.build.directory}/jacoco-report</sonar.jacoco.reportPaths>
<sonar.junit.reportPath>${project.build.directory}/surefire-reports</sonar.junit.reportPath> <sonar.junit.reportPath>${project.build.directory}/surefire-reports</sonar.junit.reportPath>
</properties> </properties>
<distributionManagement>
<repository>
<id>nexus</id>
<name>Nexus Staging Repo</name>
<url>https://repo.eclipse.org/nexus/service/local/staging/deploy/eclipsefdn/</url>
</repository>
</distributionManagement>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -36,8 +43,8 @@ ...@@ -36,8 +43,8 @@
</dependencyManagement> </dependencyManagement>
<modules> <modules>
<module>core</module> <module>core</module>
<module>persistence</module> <module>persistence</module>
<module>search</module> <module>search</module>
</modules> </modules>
<build> <build>
<plugins> <plugins>
...@@ -104,22 +111,5 @@ ...@@ -104,22 +111,5 @@
</property> </property>
</activation> </activation>
</profile> </profile>
<profile>
<id>sonar-dev</id>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</plugin>
</plugins>
</build>
<properties>
<sonar.host.url>https://sonarqube.dev.docker</sonar.host.url>
<sonar.login>admin</sonar.login>
<sonar.password>admin</sonar.password>
</properties>
</profile>
</profiles> </profiles>
</project> </project>
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