[ci] Add colors, don't fail the build/release if upload to sourceforge fails
This commit is contained in:
@ -2,9 +2,10 @@
|
||||
set -e
|
||||
|
||||
source .travis/common-functions.sh
|
||||
source .travis/colors.sh
|
||||
|
||||
VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
|
||||
echo "Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
echo_yellow "[ INFO] Building PMD Coveralls.io report ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
|
||||
if ! travis_isPush; then
|
||||
echo "Not proceeding, since this is not a push!"
|
||||
@ -16,5 +17,17 @@ fi
|
||||
# coveralls plugin seems to need java.xml.bind module
|
||||
echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se.ee'" > ${HOME}/.mavenrc
|
||||
|
||||
./mvnw clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
||||
./mvnw test jacoco:report coveralls:report -Pcoveralls -B -V
|
||||
(
|
||||
# disable fast fail, exit immediately, in this subshell
|
||||
set +e
|
||||
|
||||
./mvnw clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
||||
./mvnw test jacoco:report coveralls:report -Pcoveralls -B -V
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_red "[ERROR] Error creating coveralls report"
|
||||
else
|
||||
echo_green "[ INFO] New coveralls result: https://coveralls.io/github/pmd/pmd"
|
||||
fi
|
||||
true
|
||||
)
|
||||
|
@ -2,12 +2,13 @@
|
||||
set -e
|
||||
|
||||
source .travis/common-functions.sh
|
||||
source .travis/colors.sh
|
||||
|
||||
function push_docs() {
|
||||
if git diff --quiet docs; then
|
||||
echo "No changes in docs..."
|
||||
echo_yellow "[ INFO] No changes in docs..."
|
||||
else
|
||||
echo "Found changes in docs..."
|
||||
echo_yellow "[ INFO] Found changes in docs..."
|
||||
|
||||
if [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||
git config user.name "Travis CI (pmd-bot)"
|
||||
@ -15,45 +16,63 @@ function push_docs() {
|
||||
git add -A docs
|
||||
git commit -m "Update documentation"
|
||||
git push git@github.com:pmd/pmd.git HEAD:master
|
||||
echo_green "[ INFO] Successfully pushed docs update"
|
||||
else
|
||||
echo "Not on master branch, won't commit+push"
|
||||
echo_yellow "[ INFO] Not on master branch, won't commit+push"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
|
||||
echo "Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
echo_yellow "[ INFO] Building PMD ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
|
||||
MVN_BUILD_FLAGS="-B -V"
|
||||
|
||||
if travis_isPullRequest; then
|
||||
|
||||
echo "This is a pull-request build"
|
||||
echo_yellow "[ INFO] This is a pull-request build"
|
||||
./mvnw verify $MVN_BUILD_FLAGS
|
||||
|
||||
elif travis_isPush; then
|
||||
|
||||
if [[ "${VERSION}" != *-SNAPSHOT && "${TRAVIS_TAG}" != "" ]]; then
|
||||
echo "This is a release build for tag ${TRAVIS_TAG}"
|
||||
echo -e "\n\n"
|
||||
echo_green "[ INFO] This is a release build for tag ${TRAVIS_TAG}"
|
||||
echo -e "\n\n"
|
||||
./mvnw deploy -Possrh,pmd-release $MVN_BUILD_FLAGS
|
||||
elif [[ "${VERSION}" == *-SNAPSHOT ]]; then
|
||||
echo "This is a snapshot build"
|
||||
echo_yellow "[ INFO] This is a snapshot build"
|
||||
./mvnw deploy -Possrh $MVN_BUILD_FLAGS
|
||||
push_docs
|
||||
else
|
||||
# other build. Can happen during release: the commit with a non snapshot version is built, but not from the tag.
|
||||
echo "This is some other build, probably during release: commit with a non-snapshot version on branch master..."
|
||||
./mvnw verify -Possrh $MVN_BUILD_FLAGS
|
||||
echo_yellow "[ 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
|
||||
|
||||
# Uploading pmd distribution to sourceforge
|
||||
rsync -avh pmd-dist/target/pmd-*-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/
|
||||
rsync -avh docs/pages/release_notes.md ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md
|
||||
(
|
||||
# disable fast fail, exit immediately, in this subshell
|
||||
set +e
|
||||
|
||||
echo -e "\n\n"
|
||||
echo_yellow "[ INFO] Uploading pmd distribution to sourceforge..."
|
||||
rsync -avh pmd-dist/target/pmd-*-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_red "[ERROR] Error while uploading pmd-*-${VERSION}.zip to sourceforge!"
|
||||
echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/"
|
||||
fi
|
||||
rsync -avh docs/pages/release_notes.md ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_red "[ERROR] Error while uploading release_notes.md as ReadMe.md to sourceforge!"
|
||||
echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/"
|
||||
fi
|
||||
true
|
||||
)
|
||||
|
||||
else
|
||||
echo "This is neither a pull request nor a push!"
|
||||
echo_yellow "[ INFO] This is neither a pull request nor a push. Not executing any build."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -2,38 +2,58 @@
|
||||
set -e
|
||||
|
||||
source .travis/common-functions.sh
|
||||
source .travis/colors.sh
|
||||
|
||||
VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
|
||||
echo "Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
echo_yellow "[ INFO] Building PMD Documentation ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
|
||||
if ! travis_isPush; then
|
||||
echo "Not building site, since this is not a push!"
|
||||
echo_yellow "[ INFO] Not building site, since this is not a push!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
pushd docs
|
||||
|
||||
# run jekyll
|
||||
echo -e "\n\nBuilding documentation using jekyll...\n\n"
|
||||
echo -e "\n\n"
|
||||
echo_yellow "[ INFO] Building documentation using jekyll..."
|
||||
bundle install
|
||||
bundle exec jekyll build
|
||||
|
||||
# create pmd-doc archive
|
||||
echo -e "\n\nCreating pmd-doc archive...\n\n"
|
||||
echo -e "\n\n"
|
||||
echo_yellow "[ INFO] Creating pmd-doc archive..."
|
||||
mv _site pmd-doc-${VERSION}
|
||||
zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/
|
||||
|
||||
(
|
||||
# disable fast fail, exit immediately, in this subshell
|
||||
set +e
|
||||
|
||||
# Uploading pmd doc distribution to sourceforge
|
||||
if [[ "${TRAVIS_TAG}" != "" || "${VERSION}" == *-SNAPSHOT ]]; then
|
||||
echo -e "\n\nUploading pmd-doc archive to sourceforge...\n\n"
|
||||
rsync -avh pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/
|
||||
fi
|
||||
if [[ "${TRAVIS_TAG}" != "" || "${VERSION}" == *-SNAPSHOT ]]; then
|
||||
echo -e "\n\n"
|
||||
echo_yellow "[ INFO] Uploading pmd doc distribution to sourceforge..."
|
||||
rsync -avh pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_red "[ERROR] Couldn't upload pmd-doc-${VERSION}.zip!"
|
||||
echo_red "[ERROR] Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/"
|
||||
fi
|
||||
fi
|
||||
|
||||
# rsync site to pmd.sourceforge.net/snapshot
|
||||
if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then
|
||||
echo -e "\n\n"
|
||||
echo_yellow "[ INFO] Uploading snapshot site to pmd.sourceforge.net/snapshot..."
|
||||
travis_wait rsync -ah --stats --delete pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_red "[ERROR] Couldn't upload the snapshot documentation. It won't be current on http://pmd.sourceforge.net/snapshot/"
|
||||
else
|
||||
echo_green "[ INFO] Successfully uploaded snapshot documentation: http://pmd.sourceforge.net/snapshot/"
|
||||
fi
|
||||
fi
|
||||
|
||||
true
|
||||
)
|
||||
|
||||
# rsync site to pmd.sourceforge.net/snapshot
|
||||
if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then
|
||||
echo -e "\n\nUploading snapshot site...\n\n"
|
||||
travis_wait rsync -ah --stats --delete pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/
|
||||
fi
|
||||
|
||||
popd
|
||||
|
@ -2,9 +2,10 @@
|
||||
set -e
|
||||
|
||||
source .travis/common-functions.sh
|
||||
source .travis/colors.sh
|
||||
|
||||
VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
|
||||
echo "Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
echo_yellow "[ INFO] Building PMD Sonar ${VERSION} on branch ${TRAVIS_BRANCH}"
|
||||
|
||||
if ! travis_isPush; then
|
||||
echo "Not updating sonar, since this is not a push!"
|
||||
@ -16,5 +17,17 @@ fi
|
||||
# sonar plugin seems to need java.xml.bind module
|
||||
echo "MAVEN_OPTS='-Xms1g -Xmx1g --add-modules java.se.ee'" > ${HOME}/.mavenrc
|
||||
|
||||
# Run the build, truncate output due to Travis log limits
|
||||
./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN} -B -V
|
||||
(
|
||||
# disable fast fail, exit immediately, in this subshell
|
||||
set +e
|
||||
|
||||
# Run the build
|
||||
./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONAR_TOKEN} -B -V
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_red "[ERROR] Error updating sonar..."
|
||||
else
|
||||
echo_green "[ INFO] New sonar results: https://sonarcloud.io/dashboard?id=net.sourceforge.pmd%3Apmd"
|
||||
fi
|
||||
true
|
||||
)
|
||||
|
18
.travis/colors.sh
Normal file
18
.travis/colors.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
COL_GREEN="\e[32m"
|
||||
COL_RED="\e[31m"
|
||||
COL_RESET="\e[0m"
|
||||
COL_YELLOW="\e[33;1m"
|
||||
|
||||
function echo_red() {
|
||||
echo -e "${COL_RED}$*${COL_RESET}"
|
||||
}
|
||||
|
||||
function echo_yellow() {
|
||||
echo -e "${COL_YELLOW}$*${COL_RESET}"
|
||||
}
|
||||
|
||||
function echo_green() {
|
||||
echo -e "${COL_GREEN}$*${COL_RESET}"
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
source .travis/colors.sh
|
||||
|
||||
echo "BUILD: $BUILD"
|
||||
RELEASE_VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1)
|
||||
echo "RELEASE_VERSION: $RELEASE_VERSION"
|
||||
@ -9,10 +11,22 @@ if [ "${BUILD}" = "deploy" ]; then
|
||||
|
||||
# Deploy to ossrh has already been done with the usual build. See build-deploy.sh
|
||||
|
||||
# The site has been built before, the files have already been uploaded to sourceforge.
|
||||
# Since this is a release, making the binary the new default file...
|
||||
curl -H "Accept: application/json" -X PUT -d "default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others" \
|
||||
-d "api_key=${PMD_SF_APIKEY}" https://sourceforge.net/projects/pmd/files/pmd/${RELEASE_VERSION}/pmd-bin-${RELEASE_VERSION}.zip
|
||||
(
|
||||
# disable fast fail, exit immediately, in this subshell
|
||||
set +e
|
||||
|
||||
# The site has been built before, the files have already been uploaded to sourceforge.
|
||||
# Since this is a release, making the binary the new default file...
|
||||
echo_yellow "[ INFO] Selecting pmd-bin-${RELEASE_VERSION} as default on sourceforge.net..."
|
||||
curl -H "Accept: application/json" -X PUT -d "default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others" \
|
||||
-d "api_key=${PMD_SF_APIKEY}" https://sourceforge.net/projects/pmd/files/pmd/${RELEASE_VERSION}/pmd-bin-${RELEASE_VERSION}.zip
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_red "[ERROR] Couldn't select latest binary as default on sourceforge.net"
|
||||
else
|
||||
echo_green "[ INFO] pmd-bin-${RELEASE_VERSION} is now the default download option."
|
||||
fi
|
||||
true
|
||||
)
|
||||
|
||||
|
||||
# Assumes, the release has already been created by travis github releases provider
|
||||
@ -29,7 +43,7 @@ cat > release-edit-request.json <<EOF
|
||||
"body": "$RELEASE_BODY"
|
||||
}
|
||||
EOF
|
||||
echo "Updating release at https://api.github.com/repos/pmd/pmd/releases/${RELEASE_ID}..."
|
||||
echo_yellow "[ INFO] Updating release at https://api.github.com/repos/pmd/pmd/releases/${RELEASE_ID}..."
|
||||
|
||||
|
||||
RESPONSE=$(curl -i -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" -H "Content-Type: application/json" --data "@release-edit-request.json" -X PATCH https://api.github.com/repos/pmd/pmd/releases/${RELEASE_ID})
|
||||
@ -48,7 +62,8 @@ fi
|
||||
|
||||
if [ "${BUILD}" = "doc" ]; then
|
||||
|
||||
echo "Adding the new doc to pmd.github.io..."
|
||||
echo -e "\n\n"
|
||||
echo_yellow "[ INFO] Adding the new doc to pmd.github.io..."
|
||||
# clone pmd.github.io. Note: This uses the ssh key setup earlier
|
||||
# In order to speed things up, we use a sparse checkout - no need to checkout all directories here
|
||||
mkdir pmd.github.io
|
||||
@ -76,8 +91,26 @@ mkdir pmd.github.io
|
||||
git push origin master
|
||||
)
|
||||
|
||||
echo -e "\n\nUploading the new release to pmd.sourceforge.net which serves as an archive...\n\n"
|
||||
travis_wait rsync -ah --stats pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/pmd-${VERSION}/
|
||||
|
||||
|
||||
(
|
||||
echo -e "\n\n"
|
||||
|
||||
# disable fast fail, exit immediately, in this subshell
|
||||
set +e
|
||||
|
||||
echo_yellow "[ INFO] Uploading the new release to pmd.sourceforge.net which serves as an archive..."
|
||||
|
||||
travis_wait rsync -ah --stats pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/pmd-${RELEASE_VERSION}/
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_red "[ERROR] Uploading documentation to pmd.sourceforge.net failed..."
|
||||
echo_red "[ERROR] Please upload manually (PMD Version: ${RELEASE_VERSION})"
|
||||
else
|
||||
echo_green "[ INFO] The documentation is now available under http://pmd.sourceforge.net/pmd-${RELEASE_VERSION}/"
|
||||
fi
|
||||
true
|
||||
)
|
||||
|
||||
|
||||
fi
|
||||
|
Reference in New Issue
Block a user