forked from phoedos/pmd
b0a854619c
This reverts commit bb0813547cc85e2dd0b9c9f559c6620410ff058c.
124 lines
4.4 KiB
Bash
Executable File
124 lines
4.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
source .travis/logger.sh
|
|
source .travis/common-functions.sh
|
|
|
|
function upload_baseline() {
|
|
log_info "Generating and uploading baseline for pmdtester..."
|
|
cd ..
|
|
bundle config --local gemfile pmd/Gemfile
|
|
pmd/.travis/travis_wait "bundle exec pmdtester -m single -r ./pmd -p ${TRAVIS_BRANCH} -pc ./pmd/.travis/all-java.xml -l ./pmd/.travis/project-list.xml -f"
|
|
cd target/reports
|
|
BRANCH_FILENAME="${TRAVIS_BRANCH/\//_}"
|
|
zip -q -r ${BRANCH_FILENAME}-baseline.zip ${BRANCH_FILENAME}/
|
|
../../pmd/.travis/travis_wait "rsync -avh ${BRANCH_FILENAME}-baseline.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd-regression-tester/"
|
|
if [ $? -ne 0 ]; then
|
|
log_error "Error while uploading ${BRANCH_FILENAME}-baseline.zip to sourceforge!"
|
|
log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd-regression-tester/"
|
|
exit 1
|
|
else
|
|
log_success "Successfully uploaded ${BRANCH_FILENAME}-baseline.zip to sourceforge"
|
|
fi
|
|
}
|
|
|
|
VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec)
|
|
log_info "Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}"
|
|
|
|
MVN_BUILD_FLAGS="-B -V"
|
|
|
|
if travis_isOSX; then
|
|
|
|
log_info "The build is running on OSX"
|
|
./mvnw verify $MVN_BUILD_FLAGS
|
|
|
|
elif travis_isWindows; then
|
|
|
|
log_info "The build is running on Windows"
|
|
./mvnw verify $MVN_BUILD_FLAGS
|
|
|
|
elif travis_isPullRequest; then
|
|
|
|
log_info "This is a pull-request build"
|
|
./mvnw verify $MVN_BUILD_FLAGS
|
|
(
|
|
set +e
|
|
# Create a corresponding remote branch locally
|
|
if ! git show-ref --verify --quiet refs/heads/${TRAVIS_BRANCH}; then
|
|
git fetch --no-tags origin +refs/heads/${TRAVIS_BRANCH}:refs/remotes/origin/${TRAVIS_BRANCH}
|
|
git branch ${TRAVIS_BRANCH} origin/${TRAVIS_BRANCH}
|
|
fi
|
|
log_info "Running danger"
|
|
bundle exec danger --verbose
|
|
)
|
|
|
|
elif travis_isPush; then
|
|
|
|
if [[ "${VERSION}" != *-SNAPSHOT && "${TRAVIS_TAG}" != "" ]]; then
|
|
echo -e "\n\n"
|
|
log_info "This is a release build for tag ${TRAVIS_TAG}"
|
|
echo -e "\n\n"
|
|
./mvnw deploy -Possrh,sign,pmd-release $MVN_BUILD_FLAGS
|
|
elif [[ "${VERSION}" == *-SNAPSHOT ]]; then
|
|
log_info "This is a snapshot build"
|
|
./mvnw deploy -Possrh,sign $MVN_BUILD_FLAGS
|
|
else
|
|
# other build. Can happen during release: the commit with a non snapshot version is built, but not from the tag.
|
|
log_info "This is some other build, probably during release: commit with a non-snapshot version on branch master..."
|
|
./mvnw verify $MVN_BUILD_FLAGS
|
|
# we stop here - no need to execute further steps
|
|
exit 0
|
|
fi
|
|
|
|
(
|
|
# disable fast fail, exit immediately, in this subshell
|
|
set +e
|
|
|
|
echo -e "\n\n"
|
|
log_info "Uploading pmd distribution to sourceforge..."
|
|
.travis/travis_wait "rsync -avh pmd-dist/target/pmd-*-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/"
|
|
if [ $? -ne 0 ]; then
|
|
log_error "Error while uploading pmd-*-${VERSION}.zip to sourceforge!"
|
|
log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/"
|
|
exit 1
|
|
else
|
|
log_success "Successfully uploaded pmd-*-${VERSION}.zip to sourceforge"
|
|
fi
|
|
|
|
)
|
|
|
|
( # UPLOAD RELEASE NOTES TO SOURCEFORGE
|
|
|
|
# This handler is called if any command fails
|
|
function release_notes_fail() {
|
|
log_error "Error while uploading release_notes.md as ReadMe.md to sourceforge!"
|
|
log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/"
|
|
}
|
|
|
|
# exit subshell after trap
|
|
set -e
|
|
trap release_notes_fail ERR
|
|
|
|
RELEASE_NOTES_TMP=$(mktemp -t)
|
|
|
|
bundle exec .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6 > "$RELEASE_NOTES_TMP"
|
|
|
|
rsync -avh "$RELEASE_NOTES_TMP" ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md
|
|
|
|
log_success "Successfully uploaded release_notes.md as ReadMe.md to sourceforge"
|
|
|
|
)
|
|
|
|
|
|
(
|
|
# disable fast fail, exit immediately, in this subshell
|
|
set +e
|
|
|
|
upload_baseline
|
|
)
|
|
|
|
else
|
|
log_info "This is neither a pull request nor a push. Not executing any build."
|
|
exit 1
|
|
fi
|