CI/CD build and release jobs
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
diff --git a/etc/jenkins/Jenkinsfile_EE4J_build b/etc/jenkins/Jenkinsfile_EE4J_build
index 9ac5a23..65a8b56 100644
--- a/etc/jenkins/Jenkinsfile_EE4J_build
+++ b/etc/jenkins/Jenkinsfile_EE4J_build
@@ -10,8 +10,11 @@
maven 'apache-maven-latest'
}
environment {
- MVN = 'mvn -B -q -Ddoclint=none -Dadditionalparam="-Xdoclint:none" -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
+ MVN = 'mvn -B -q -Ddoclint=none -Dmaven.test.failure.ignore=true -Dadditionalparam="-Xdoclint:none" -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
REPO='git@github.com:eclipse-ee4j/jersey.git'
+ SECRET_FILE_ID='6474d9ed-eadc-47a0-8f60-43277c1cad52'
+ SECURITY_FILE_ID='8e6103e6-a03e-44fe-bd9a-a4ed070d9b56'
+ CONFIG_FILE_ID='c88e58d9-97bd-4f06-af82-fd469abcedea'
CREDENTIALS_ID='f5848e71-9994-45e3-8214-137ce91ddbcf'
BUILD_BRANCH='EE4J_8'
}
@@ -23,8 +26,8 @@
}
stage('Nightly Build') {
steps {
- withCredentials([file(credentialsId: '6474d9ed-eadc-47a0-8f60-43277c1cad52', variable: 'KEYRING')]) {
- configFileProvider([configFile(fileId: '8e6103e6-a03e-44fe-bd9a-a4ed070d9b56', targetLocation: '/home/jenkins/.m2/')]) {
+ withCredentials([file(credentialsId: SECRET_FILE_ID, variable: 'KEYRING')]) {
+ configFileProvider([configFile(fileId: SECURITY_FILE_ID, targetLocation: '/home/jenkins/.m2/')]) {
//# Workaround: GPG initialization
sh("gpg --batch --import ${KEYRING}")
@@ -34,13 +37,18 @@
echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust;
done
'''
- configFileProvider([configFile(fileId: 'c88e58d9-97bd-4f06-af82-fd469abcedea', variable: 'MAVEN_SETTINGS_XML')]) {
+ configFileProvider([configFile(fileId: CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_XML')]) {
sh "$MVN -s $MAVEN_SETTINGS_XML clean install"
}
}
}
}
+ post {
+ always {
+ archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/**.jar', fingerprint: true, onlyIfSuccessful: true
+ junit allowEmptyResults: true, testResults:'**/target/surefire-reports/*.xml'
+ }
+ }
}
}
-}
-
+}
\ No newline at end of file
diff --git a/etc/jenkins/Jenkinsfile_master_build b/etc/jenkins/Jenkinsfile_master_build
index 4993706..a4c5483 100644
--- a/etc/jenkins/Jenkinsfile_master_build
+++ b/etc/jenkins/Jenkinsfile_master_build
@@ -10,8 +10,11 @@
maven 'apache-maven-latest'
}
environment {
- MVN = 'mvn -B -q -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
+ MVN = 'mvn -B -q -Dmaven.test.failure.ignore=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
REPO='git@github.com:eclipse-ee4j/jersey.git'
+ SECRET_FILE_ID='6474d9ed-eadc-47a0-8f60-43277c1cad52'
+ SECURITY_FILE_ID='8e6103e6-a03e-44fe-bd9a-a4ed070d9b56'
+ CONFIG_FILE_ID='c88e58d9-97bd-4f06-af82-fd469abcedea'
CREDENTIALS_ID='f5848e71-9994-45e3-8214-137ce91ddbcf'
BUILD_BRANCH='master'
}
@@ -23,8 +26,8 @@
}
stage('Nightly Build') {
steps {
- withCredentials([file(credentialsId: '6474d9ed-eadc-47a0-8f60-43277c1cad52', variable: 'KEYRING')]) {
- configFileProvider([configFile(fileId: '8e6103e6-a03e-44fe-bd9a-a4ed070d9b56', targetLocation: '/home/jenkins/.m2/')]) {
+ withCredentials([file(credentialsId: SECRET_FILE_ID, variable: 'KEYRING')]) {
+ configFileProvider([configFile(fileId: SECURITY_FILE_ID, targetLocation: '/home/jenkins/.m2/')]) {
//# Workaround: GPG initialization
sh("gpg --batch --import ${KEYRING}")
@@ -34,13 +37,18 @@
echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust;
done
'''
- configFileProvider([configFile(fileId: 'c88e58d9-97bd-4f06-af82-fd469abcedea', variable: 'MAVEN_SETTINGS_XML')]) {
+ configFileProvider([configFile(fileId: CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_XML')]) {
sh "$MVN -s $MAVEN_SETTINGS_XML clean install"
}
}
}
}
+ post {
+ always {
+ archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/**.jar', fingerprint: true, onlyIfSuccessful: true
+ junit allowEmptyResults: true, testResults:'**/target/surefire-reports/*.xml'
+ }
+ }
}
}
-}
-
+}
\ No newline at end of file
diff --git a/etc/jenkins/Jenkinsfile_release b/etc/jenkins/Jenkinsfile_release
index a0897d1..6fce5ed 100644
--- a/etc/jenkins/Jenkinsfile_release
+++ b/etc/jenkins/Jenkinsfile_release
@@ -8,11 +8,14 @@
def RELEASE_VERSION=RELEASE_VERSION
def NEXT_VERSION=NEXT_VERSION
def RELEASE_TAG=''
- def OVERWRITE='false'
+ def OVERWRITE=OVERWRITE
def PROJECT_NAME='Jersey'
def LOGIN='jersey-bot'
def EMAIL = 'jersey-bot@eclipse.org'
def REPO='git@github.com:eclipse-ee4j/jersey.git'
+ def SECRET_FILE_ID='6474d9ed-eadc-47a0-8f60-43277c1cad52'
+ def SECURITY_FILE_ID='8e6103e6-a03e-44fe-bd9a-a4ed070d9b56'
+ def CONFIG_FILE_ID='c88e58d9-97bd-4f06-af82-fd469abcedea'
def CREDENTIALS_ID='f5848e71-9994-45e3-8214-137ce91ddbcf'
def GIT_ORIGIN='origin'
def RELEASE_FOLDER='.'
@@ -67,11 +70,15 @@
echo '-[ Dry run turned on ]----------------------------------------------------------'
TARGET = 'install'
}
+ echo '-[ Configure git user ]--------------------------------------------------------'
+ sh "git config --local user.email \"${EMAIL}\""
+ sh "git config --local user.name \"$LOGIN\""
+
}
}
stage ('Prepare GPG') {
- withCredentials([file(credentialsId: '6474d9ed-eadc-47a0-8f60-43277c1cad52', variable: 'KEYRING')]) {
+ withCredentials([file(credentialsId: SECRET_FILE_ID, variable: 'KEYRING')]) {
//# Workaround: GPG initialization
sh("gpg --batch --import ${KEYRING}")
sh '''
@@ -90,7 +97,9 @@
if (BRANCH_CHECK) {
if ( OVERWRITE == 'true' ) {
echo "${GIT_ORIGIN}/${RELEASE_VERSION} branch already exists, deleting"
- sh 'git push --delete ${GIT_ORIGIN} ${RELEASE_VERSION} && true'
+ sshagent([CREDENTIALS_ID]) {
+ sh "git push ${GIT_ORIGIN} :${RELEASE_VERSION} && true"
+ }
} else {
error "${GIT_ORIGIN}/${RELEASE_VERSION} branch already exists"
}
@@ -108,7 +117,9 @@
if (TAG_CHECK) {
if (OVERWRITE == 'true' ) {
echo "${RELEASE_TAG} tag already exists, deleting"
- sh "git push --delete origin ${RELEASE_TAG} && true"
+ sshagent([CREDENTIALS_ID]) {
+ sh "git push --delete origin ${RELEASE_TAG} && true"
+ }
} else {
error "${RELEASE_TAG} tag already exists"
}
@@ -130,29 +141,16 @@
"""
echo '-[ Run release build ]---------------------------------------------------------'
dir (RELEASE_FOLDER) {
- withCredentials([file(credentialsId: '6474d9ed-eadc-47a0-8f60-43277c1cad52', variable: 'KEYRING')]) {
- configFileProvider([configFile(fileId: '8e6103e6-a03e-44fe-bd9a-a4ed070d9b56', targetLocation: '/home/jenkins/.m2/')]) {
+ configFileProvider([configFile(fileId: SECURITY_FILE_ID, targetLocation: '/home/jenkins/.m2/')]) {
- //# Workaround: GPG initialization
- sh("gpg --batch --import ${KEYRING}")
- sh '''
- for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u);
- do
- echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust;
- done
- '''
- configFileProvider([configFile(fileId: 'c88e58d9-97bd-4f06-af82-fd469abcedea', variable: 'MAVEN_SETTINGS_XML')]) {
+ configFileProvider([configFile(fileId: CONFIG_FILE_ID, variable: 'MAVEN_SETTINGS_XML')]) {
sh "${MVN_HOME}/bin/mvn -q -B -s ${MAVEN_SETTINGS_XML} -DskipTests -Ddoclint=none -Dadditionalparam='-Xdoclint:none' " +
" -U -C clean package source:jar javadoc:jar ${TARGET}"
}
}
- }
}
}
stage ('Prepare release') {
- echo '-[ Configure git user ]--------------------------------------------------------'
- sh "git config --local user.email \"${EMAIL}\""
- sh "git config --local user.name \"$LOGIN\""
echo '-[ Perform release commit to git ]---------------------------------------------'
sh "git commit -a -m ${RELEASE_VERSION}"
sh "git tag -m ${RELEASE_TAG} -a ${RELEASE_TAG}"
@@ -176,9 +174,10 @@
sh "git push ${GIT_ORIGIN} ${RELEASE_VERSION} --dry-run"
}
return
- }
- sshagent([CREDENTIALS_ID]) {
- sh "git push ${GIT_ORIGIN} ${RELEASE_VERSION} --follow-tags"
+ } else {
+ sshagent([CREDENTIALS_ID]) {
+ sh "git push ${GIT_ORIGIN} ${RELEASE_VERSION} --follow-tags"
+ }
}
}
}
\ No newline at end of file