forked from phoedos/pmd
[ci] Fix shellcheck issues
This commit is contained in:
parent
417cc7fcbe
commit
640b3fcab3
28
.ci/build.sh
28
.ci/build.sh
@ -12,11 +12,11 @@ function build() {
|
||||
pmd_ci_log_group_start "Prepare Java 7+11, Bundler"
|
||||
pmd_ci_openjdk_install_adoptopenjdk 11
|
||||
pmd_ci_openjdk_setdefault 11
|
||||
PMD_MAVEN_EXTRA_OPTS=""
|
||||
PMD_MAVEN_EXTRA_OPTS=()
|
||||
if [ "$(pmd_ci_utils_get_os)" = "linux" ]; then
|
||||
log_info "Install openjdk7 for integration tests"
|
||||
pmd_ci_log_info "Install openjdk7 for integration tests"
|
||||
pmd_ci_openjdk_install_zuluopenjdk 7
|
||||
PMD_MAVEN_EXTRA_OPTS="-Djava7.home=${HOME}/oraclejdk7"
|
||||
PMD_MAVEN_EXTRA_OPTS=(-Djava7.home="${HOME}/oraclejdk7")
|
||||
fi
|
||||
pmd_ci_build_setup_bundler
|
||||
pmd_ci_log_group_end
|
||||
@ -28,7 +28,7 @@ function build() {
|
||||
|
||||
if pmd_ci_utils_is_fork_or_pull_request; then
|
||||
pmd_ci_log_group_start "Build with mvnw"
|
||||
./mvnw clean verify --show-version --errors --batch-mode --no-transfer-progress ${PMD_MAVEN_EXTRA_OPTS}
|
||||
./mvnw clean verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}"
|
||||
pmd_ci_log_group_end
|
||||
|
||||
# Danger is executed only on the linux runner
|
||||
@ -45,7 +45,7 @@ function build() {
|
||||
|
||||
if [ "$(pmd_ci_utils_get_os)" != "linux" ]; then
|
||||
pmd_ci_log_group_start "Build with mvnw"
|
||||
./mvnw clean verify --show-version --errors --batch-mode --no-transfer-progress ${PMD_MAVEN_EXTRA_OPTS}
|
||||
./mvnw clean verify --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}"
|
||||
pmd_ci_log_group_end
|
||||
|
||||
pmd_ci_log_info "Stopping build here, because os is not linux"
|
||||
@ -91,7 +91,7 @@ function build() {
|
||||
-Dpmd.skip \
|
||||
--show-version --errors --batch-mode --no-transfer-progress \
|
||||
clean package \
|
||||
sonar:sonar -Dsonar.login=${SONAR_TOKEN} -Psonar
|
||||
sonar:sonar -Dsonar.login="${SONAR_TOKEN}" -Psonar
|
||||
pmd_ci_log_success "New sonar results: https://sonarcloud.io/dashboard?id=net.sourceforge.pmd%3Apmd"
|
||||
pmd_ci_log_group_end
|
||||
|
||||
@ -104,7 +104,7 @@ function build() {
|
||||
-Dmaven.source.skip \
|
||||
-Dcheckstyle.skip \
|
||||
-Dpmd.skip \
|
||||
-DrepoToken=${COVERALLS_REPO_TOKEN} \
|
||||
-DrepoToken="${COVERALLS_REPO_TOKEN}" \
|
||||
--show-version --errors --batch-mode --no-transfer-progress \
|
||||
clean package jacoco:report \
|
||||
coveralls:report -Pcoveralls
|
||||
@ -118,7 +118,7 @@ function build() {
|
||||
# Installs bundler, which is needed for doc generation and regression tester
|
||||
#
|
||||
function pmd_ci_build_setup_bundler() {
|
||||
log_info "Installing bundler..."
|
||||
pmd_ci_log_info "Installing bundler..."
|
||||
gem install bundler
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ function pmd_ci_build_run() {
|
||||
pmd_ci_log_info "This is a snapshot build"
|
||||
fi
|
||||
|
||||
./mvnw clean deploy -P${mvn_profiles} --show-version --errors --batch-mode --no-transfer-progress ${PMD_MAVEN_EXTRA_OPTS}
|
||||
./mvnw clean deploy -P${mvn_profiles} --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}"
|
||||
}
|
||||
|
||||
#
|
||||
@ -150,7 +150,7 @@ function pmd_ci_deploy_build_artifacts() {
|
||||
|
||||
if pmd_ci_maven_isReleaseBuild; then
|
||||
# create a draft github release
|
||||
pmd_ci_gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 ${PMD_CI_TAG})"
|
||||
pmd_ci_gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 "${PMD_CI_TAG}")"
|
||||
GH_RELEASE="$RESULT"
|
||||
|
||||
# Deploy to github releases
|
||||
@ -176,7 +176,7 @@ function pmd_ci_build_and_upload_doc() {
|
||||
# Deploy javadoc to https://docs.pmd-code.org/apidocs/*/${PMD_CI_MAVEN_PROJECT_VERSION}/
|
||||
pmd_code_uploadJavadoc "${PMD_CI_MAVEN_PROJECT_VERSION}" "$(pwd)"
|
||||
|
||||
if [ pmd_ci_maven_isSnapshotBuild && "${PMD_CI_BRANCH}" = "master" ]; then
|
||||
if pmd_ci_maven_isSnapshotBuild && [ "${PMD_CI_BRANCH}" = "master" ]; then
|
||||
# only for snapshot builds from branch master
|
||||
pmd_code_createSymlink "${PMD_CI_MAVEN_PROJECT_VERSION}" "snapshot"
|
||||
|
||||
@ -202,8 +202,10 @@ function pmd_ci_build_and_upload_doc() {
|
||||
bundle config set --local with release_notes_preprocessing
|
||||
bundle install
|
||||
# renders, and skips the first 6 lines - the Jekyll front-matter
|
||||
local rendered_release_notes=$(bundle exec .ci/render_release_notes.rb docs/pages/release_notes.md | tail -n +6)
|
||||
local release_name="PMD ${PMD_CI_MAVEN_PROJECT_VERSION} ($(date -u +%d-%B-%Y))"
|
||||
local rendered_release_notes
|
||||
rendered_release_notes=$(bundle exec .ci/render_release_notes.rb docs/pages/release_notes.md | tail -n +6)
|
||||
local release_name
|
||||
release_name="PMD ${PMD_CI_MAVEN_PROJECT_VERSION} ($(date -u +%d-%B-%Y))"
|
||||
pmd_ci_gh_releases_updateRelease "$GH_RELEASE" "$release_name" "$rendered_release_notes"
|
||||
pmd_ci_sourceforge_uploadReleaseNotes "${PMD_CI_MAVEN_PROJECT_VERSION}" "${rendered_release_notes}"
|
||||
|
||||
|
@ -9,78 +9,84 @@ PMD_CODE_SSH_USER=pmd
|
||||
PMD_CODE_DOCS_PATH=/docs.pmd-code.org/
|
||||
|
||||
function pmd_code_uploadDocumentation() {
|
||||
local pmdVersion="$1"
|
||||
local filename="$2"
|
||||
local basefilename="$(basename $filename)"
|
||||
local -r pmdVersion="$1"
|
||||
local -r filename="$2"
|
||||
local -r basefilename="$(basename "$filename")"
|
||||
|
||||
pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion filename=$filename"
|
||||
pmd_ci_log_debug "${FUNCNAME[0]} pmdVersion=$pmdVersion filename=$filename"
|
||||
|
||||
scp "${filename}" ${PMD_CODE_SSH_USER}@pmd-code.org:${PMD_CODE_DOCS_PATH}
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
|
||||
unzip -qo ${basefilename} && \
|
||||
rm ${basefilename}"
|
||||
# shellcheck disable=SC2029
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd \"${PMD_CODE_DOCS_PATH}\" && \
|
||||
unzip -qo \"${basefilename}\" && \
|
||||
rm \"${basefilename}\""
|
||||
pmd_ci_log_info "Docs updated: https://docs.pmd-code.org/pmd-doc-${pmdVersion}/"
|
||||
}
|
||||
|
||||
function pmd_code_removeDocumentation() {
|
||||
local pmdVersion="$1"
|
||||
|
||||
pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion"
|
||||
pmd_ci_log_debug "${FUNCNAME[0]} pmdVersion=$pmdVersion"
|
||||
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
|
||||
rm -rf pmd-doc-${pmdVersion}/"
|
||||
# shellcheck disable=SC2029
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd \"${PMD_CODE_DOCS_PATH}\" && \
|
||||
rm -rf \"pmd-doc-${pmdVersion}/\""
|
||||
pmd_ci_log_info "Removed docs: https://docs.pmd-code.org/pmd-doc-${pmdVersion}/"
|
||||
}
|
||||
|
||||
function pmd_code_createSymlink() {
|
||||
local pmdVersion="$1"
|
||||
local name="$2"
|
||||
local -r pmdVersion="$1"
|
||||
local -r name="$2"
|
||||
|
||||
pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion name=$name"
|
||||
pmd_ci_log_debug "${FUNCNAME[0]} pmdVersion=$pmdVersion name=$name"
|
||||
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
|
||||
rm -f $name && \
|
||||
ln -s pmd-doc-${pmdVersion} $name"
|
||||
# shellcheck disable=SC2029
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd \"${PMD_CODE_DOCS_PATH}\" && \
|
||||
rm -f \"$name\" && \
|
||||
ln -s \"pmd-doc-${pmdVersion}\" \"$name\""
|
||||
pmd_ci_log_info "Symlink created: https://docs.pmd-code.org/$name/ -> https://docs.pmd-code.org/pmd-doc-${pmdVersion}/"
|
||||
}
|
||||
|
||||
function pmd_code_uploadJavadoc() {
|
||||
local pmdVersion="$1"
|
||||
local basePath="$2"
|
||||
local -r pmdVersion="$1"
|
||||
local -r basePath="$2"
|
||||
|
||||
pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion basePath=$basePath"
|
||||
pmd_ci_log_debug "${FUNCNAME[0]} pmdVersion=$pmdVersion basePath=$basePath"
|
||||
|
||||
for i in ${basePath}/*/target/*-javadoc.jar */*/target/*-javadoc.jar; do
|
||||
for i in "${basePath}"/*/target/*-javadoc.jar */*/target/*-javadoc.jar; do
|
||||
pmd_code_uploadJavadocModule "$pmdVersion" "$i"
|
||||
done
|
||||
|
||||
# make sure https://docs.pmd-code.org/apidocs/ shows directory index
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH}/apidocs && \
|
||||
# shellcheck disable=SC2029
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd \"${PMD_CODE_DOCS_PATH}/apidocs\" && \
|
||||
echo 'Options +Indexes' > .htaccess"
|
||||
pmd_ci_log_info "Directory index enabled for https://docs.pmd-code.org/apidocs/"
|
||||
}
|
||||
|
||||
function pmd_code_uploadJavadocModule() {
|
||||
local pmdVersion="$1"
|
||||
local moduleJavadocJar="$2"
|
||||
local moduleJavadocJarBasename="$(basename $moduleJavadocJar)"
|
||||
local module=${moduleJavadocJarBasename%%-${pmdVersion}-javadoc.jar}
|
||||
local -r pmdVersion="$1"
|
||||
local -r moduleJavadocJar="$2"
|
||||
local -r moduleJavadocJarBasename="$(basename "$moduleJavadocJar")"
|
||||
local -r module=${moduleJavadocJarBasename%%-${pmdVersion}-javadoc.jar}
|
||||
|
||||
pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion moduleJavadocJar=$moduleJavadocJar module=$module"
|
||||
pmd_ci_log_debug "${FUNCNAME[0]} pmdVersion=$pmdVersion moduleJavadocJar=$moduleJavadocJar module=$module"
|
||||
|
||||
scp "$moduleJavadocJar" ${PMD_CODE_SSH_USER}@pmd-code.org:${PMD_CODE_DOCS_PATH}
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
|
||||
mkdir -p apidocs/${module}/${pmdVersion} && \
|
||||
unzip -qo -d apidocs/${module}/${pmdVersion} ${moduleJavadocJarBasename} && \
|
||||
rm ${moduleJavadocJarBasename}"
|
||||
# shellcheck disable=SC2029
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd \"${PMD_CODE_DOCS_PATH}\" && \
|
||||
mkdir -p \"apidocs/${module}/${pmdVersion}\" && \
|
||||
unzip -qo -d \"apidocs/${module}/${pmdVersion}\" \"${moduleJavadocJarBasename}\" && \
|
||||
rm \"${moduleJavadocJarBasename}\""
|
||||
pmd_ci_log_info "JavaDoc for $module uploaded: https://docs.pmd-code.org/apidocs/${module}/${pmdVersion}/"
|
||||
}
|
||||
|
||||
function pmd_code_removeJavadoc() {
|
||||
local pmdVersion="$1"
|
||||
local -r pmdVersion="$1"
|
||||
|
||||
pmd_ci_log_debug "$FUNCNAME pmdVersion=$pmdVersion"
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
|
||||
rm -rf apidocs/*/${pmdVersion}"
|
||||
pmd_ci_log_debug "${FUNCNAME[0]} pmdVersion=$pmdVersion"
|
||||
# shellcheck disable=SC2029
|
||||
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd \"${PMD_CODE_DOCS_PATH}\" && \
|
||||
rm -rf apidocs/*/\"${pmdVersion}\""
|
||||
pmd_ci_log_info "Removed Javadoc: https://docs.pmd-code.org/apidocs/*/${pmdVersion}/ is gone"
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ source "$(dirname "$0")/inc/fetch_ci_scripts.bash" && fetch_ci_scripts
|
||||
# The documentation will be generated in the directory "docs/_site".
|
||||
#
|
||||
function pmd_doc_generate_jekyll_site() {
|
||||
pushd docs
|
||||
pushd docs || { echo "Directory 'docs' doesn't exist"; exit 1; }
|
||||
|
||||
echo -e "\n\n"
|
||||
pmd_ci_log_info "Building documentation using jekyll..."
|
||||
@ -23,22 +23,22 @@ function pmd_doc_generate_jekyll_site() {
|
||||
bundle install
|
||||
bundle exec jekyll build
|
||||
|
||||
popd
|
||||
popd || exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# Creates the pmd-doc.zip archive. It will be placed in "docs/".
|
||||
#
|
||||
function pmd_doc_create_archive() {
|
||||
pushd docs
|
||||
pushd docs || { echo "Directory 'docs' doesn't exist"; exit 1; }
|
||||
|
||||
echo -e "\n\n"
|
||||
pmd_ci_log_info "Creating pmd-doc archive..."
|
||||
mv _site pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}
|
||||
zip -qr pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}.zip pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/
|
||||
mv _site "pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}"
|
||||
zip -qr "pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}.zip" "pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/"
|
||||
pmd_ci_log_success "Successfully created pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}.zip"
|
||||
|
||||
popd
|
||||
popd || exit 1
|
||||
}
|
||||
|
||||
#
|
||||
@ -52,7 +52,7 @@ function publish_release_documentation_github() {
|
||||
# In order to speed things up, we use a sparse checkout - no need to checkout all directories here
|
||||
mkdir pmd.github.io
|
||||
(
|
||||
cd pmd.github.io
|
||||
cd pmd.github.io || { echo "Directory 'pmd.github.io' doesn't exist"; exit 1; }
|
||||
git init
|
||||
git config user.name "PMD CI (pmd-bot)"
|
||||
git config user.email "andreas.dangel+pmd-bot@adangel.org"
|
||||
@ -62,16 +62,16 @@ function publish_release_documentation_github() {
|
||||
echo "/sitemap.xml" >> .git/info/sparse-checkout
|
||||
git pull --depth=1 origin master
|
||||
pmd_ci_log_info "Copying documentation from ../docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/ to pmd-${PMD_CI_MAVEN_PROJECT_VERSION}/ ..."
|
||||
rsync -ah --stats ../docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/ pmd-${PMD_CI_MAVEN_PROJECT_VERSION}/
|
||||
rsync -ah --stats "../docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/" "pmd-${PMD_CI_MAVEN_PROJECT_VERSION}/"
|
||||
git status
|
||||
pmd_ci_log_debug "Executing: git add pmd-${PMD_CI_MAVEN_PROJECT_VERSION}"
|
||||
git add pmd-${PMD_CI_MAVEN_PROJECT_VERSION}
|
||||
git add "pmd-${PMD_CI_MAVEN_PROJECT_VERSION}"
|
||||
pmd_ci_log_debug "Executing: git commit..."
|
||||
git commit -q -m "Added pmd-${PMD_CI_MAVEN_PROJECT_VERSION}"
|
||||
|
||||
pmd_ci_log_info "Copying pmd-${PMD_CI_MAVEN_PROJECT_VERSION} to latest ..."
|
||||
git rm -qr latest
|
||||
cp -a pmd-${PMD_CI_MAVEN_PROJECT_VERSION} latest
|
||||
cp -a "pmd-${PMD_CI_MAVEN_PROJECT_VERSION}" latest
|
||||
pmd_ci_log_debug "Executing: git add latest"
|
||||
git add latest
|
||||
pmd_ci_log_debug "Executing: git commit..."
|
||||
@ -100,9 +100,9 @@ function pmd_doc_publish_to_github_pages() {
|
||||
# clear the files first
|
||||
rm -rf pmd-gh-pages/*
|
||||
# copy the new site
|
||||
cp -a docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}/* pmd-gh-pages/
|
||||
cp -a "docs/pmd-doc-${PMD_CI_MAVEN_PROJECT_VERSION}"/* pmd-gh-pages/
|
||||
(
|
||||
cd pmd-gh-pages
|
||||
cd pmd-gh-pages || { echo "Directory 'pmd-gh-pages' doesn't exist"; exit 1; }
|
||||
git config user.name "PMD CI (pmd-bot)"
|
||||
git config user.email "andreas.dangel+pmd-bot@adangel.org"
|
||||
git add -A
|
||||
|
@ -74,7 +74,7 @@ function regression_tester_executeDanger() {
|
||||
if ! git show-ref --verify --quiet refs/heads/${PMD_CI_BRANCH}; then
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/${PMD_CI_BRANCH}:refs/remotes/origin/${PMD_CI_BRANCH}
|
||||
git branch ${PMD_CI_BRANCH} origin/${PMD_CI_BRANCH}
|
||||
log_debug "Created local branch ${PMD_CI_BRANCH}"
|
||||
pmd_ci_log_debug "Created local branch ${PMD_CI_BRANCH}"
|
||||
fi
|
||||
# Fetch more commits of the PR for danger and regression tester
|
||||
git fetch --no-tags --depth=50 origin +$(git rev-parse HEAD^2):
|
||||
|
Loading…
x
Reference in New Issue
Block a user