Abandon travis-ci for jenkins
moparisthebest/jBgJob/pipeline/head This commit looks good Details

This commit is contained in:
Travis Burtrum 2020-11-18 00:43:36 -05:00
parent 9fd06f7a77
commit e61b21b3d3
4 changed files with 67 additions and 49 deletions

42
.ci/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,42 @@
properties(
[
disableConcurrentBuilds()
]
)
node('linux && docker') {
try {
stage('Checkout') {
//branch name from Jenkins environment variables
echo "My branch is: ${env.BRANCH_NAME}"
// this doesn't grab tags pointing to this branch
//checkout scm
// this hack does... https://issues.jenkins.io/browse/JENKINS-45164
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/'+env.BRANCH_NAME]],
extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
userRemoteConfigs: scm.userRemoteConfigs,
])
sh '''
set -euxo pipefail
git checkout "$BRANCH_NAME" --
git reset --hard "origin/$BRANCH_NAME"
'''
}
stage('Build + Deploy') {
sh 'curl --compressed -sL https://code.moparisthebest.com/moparisthebest/self-ci/raw/branch/master/build-ci.sh | bash'
}
currentBuild.result = 'SUCCESS'
} catch (Exception err) {
currentBuild.result = 'FAILURE'
} finally {
stage('Email') {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'admin.jenkins@moparisthebest.com', sendToIndividuals: true])
}
deleteDir()
}
}

25
.ci/build.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -euxo pipefail
[ $JAVA_VERSION -lt 8 ] && echo "build does not support JAVA_VERSION: $JAVA_VERSION" && exit 0
echo "starting build for JAVA_VERSION: $JAVA_VERSION"
# install deps
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
# clean and test
mvn clean test -B
# publish only from java 8 and master branch
if [ "$BRANCH_NAME" == "master" -a $JAVA_VERSION -eq 8 ]
then
echo 'deploying to maven'
mvn deploy -Dmaven.test.skip=true -B
mkdir -p release
find -type f -name '*.jar' -print0 | xargs -0n1 -I {} mv '{}' 'release/'
fi
echo 'build success!'
exit 0

View File

@ -1,9 +0,0 @@
<settings>
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>

View File

@ -1,40 +0,0 @@
language: java
sudo: false
services:
- redis-server
script:
- mvn test -B -Dmaven.test.skip=false
matrix:
include:
- env: JDK='OpenJDK 8'
jdk: openjdk8
- env: JDK='OracleJDK 8'
jdk: oraclejdk8
- env: JDK='OpenJDK 9'
install: . ./install-jdk.sh -F 9 -L GPL
- env: JDK='OracleJDK 9'
jdk: oraclejdk9
- env: JDK='OpenJDK 10'
install: . ./install-jdk.sh -F 10 -L GPL
- env: JDK='OpenJDK 11'
install: . ./install-jdk.sh -F 11 -L GPL
- env: JDK='OpenJDK 12'
install: . ./install-jdk.sh -F 12 -L GPL
- env: JDK='OpenJDK 13'
install: . ./install-jdk.sh -F 13 -L GPL
- env: JDK='OpenJDK 14'
install: . ./install-jdk.sh -F 14 -L GPL
before_install: wget https://raw.githubusercontent.com/sormuras/bach/master/install-jdk.sh
after_success:
- if [[ "${JDK}" == 'OpenJDK 8' && "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" == 'master' ]]; then
mvn deploy --settings .travis-settings.xml -Dmaven.test.skip=true -B || travis_terminate 1;
fi
cache:
directories:
- $HOME/.m2