Run shellcheck on build (#499)
And fix all the errors and warnings reported
This commit is contained in:
parent
6b5d3f03bf
commit
ed1a330c47
|
@ -13,8 +13,17 @@ node('docker') {
|
|||
}
|
||||
|
||||
if (!infra.isTrusted()) {
|
||||
|
||||
stage('shellcheck') {
|
||||
docker.image('koalaman/shellcheck').inside() {
|
||||
// run shellcheck ignoring error SC1091
|
||||
// Not following: /usr/local/bin/jenkins-support was not specified as input
|
||||
sh "shellcheck -e SC1091 *.sh"
|
||||
}
|
||||
}
|
||||
|
||||
/* Outside of the trusted.ci environment, we're building and testing
|
||||
* the Dockerful in this repository, but not publishing to docker hub
|
||||
* the Dockerfile in this repository, but not publishing to docker hub
|
||||
*/
|
||||
stage('Build') {
|
||||
docker.build('jenkins')
|
||||
|
|
|
@ -67,7 +67,7 @@ doDownload() {
|
|||
url="$JENKINS_UC_DOWNLOAD/plugins/$plugin/$version/${plugin}.hpi"
|
||||
|
||||
echo "Downloading plugin: $plugin from $url"
|
||||
curl --connect-timeout ${CURL_CONNECTION_TIMEOUT:-20} --retry ${CURL_RETRY:-5} --retry-delay ${CURL_RETRY_DELAY:-0} --retry-max-time ${CURL_RETRY_MAX_TIME:-60} -s -f -L "$url" -o "$jpi"
|
||||
curl --connect-timeout "${CURL_CONNECTION_TIMEOUT:-20}" --retry "${CURL_RETRY:-5}" --retry-delay "${CURL_RETRY_DELAY:-0}" --retry-max-time "${CURL_RETRY_MAX_TIME:-60}" -s -f -L "$url" -o "$jpi"
|
||||
return $?
|
||||
}
|
||||
|
||||
|
@ -126,13 +126,13 @@ bundledPlugins() {
|
|||
if [ -f $JENKINS_WAR ]
|
||||
then
|
||||
TEMP_PLUGIN_DIR=/tmp/plugintemp.$$
|
||||
for i in $(jar tf $JENKINS_WAR | egrep '[^detached-]plugins.*\..pi' | sort)
|
||||
for i in $(jar tf $JENKINS_WAR | grep -E '[^detached-]plugins.*\..pi' | sort)
|
||||
do
|
||||
rm -fr $TEMP_PLUGIN_DIR
|
||||
mkdir -p $TEMP_PLUGIN_DIR
|
||||
PLUGIN=$(basename "$i"|cut -f1 -d'.')
|
||||
(cd $TEMP_PLUGIN_DIR;jar xf "$JENKINS_WAR" "$i";jar xvf "$TEMP_PLUGIN_DIR/$i" META-INF/MANIFEST.MF >/dev/null 2>&1)
|
||||
VER=$(egrep -i Plugin-Version "$TEMP_PLUGIN_DIR/META-INF/MANIFEST.MF"|cut -d: -f2|sed 's/ //')
|
||||
VER=$(grep -E -i Plugin-Version "$TEMP_PLUGIN_DIR/META-INF/MANIFEST.MF"|cut -d: -f2|sed 's/ //')
|
||||
echo "$PLUGIN:$VER"
|
||||
done
|
||||
rm -fr $TEMP_PLUGIN_DIR
|
||||
|
@ -160,22 +160,23 @@ installedPlugins() {
|
|||
}
|
||||
|
||||
main() {
|
||||
local plugin plugins version
|
||||
local plugin version
|
||||
local plugins=()
|
||||
|
||||
mkdir -p "$REF_DIR" || exit 1
|
||||
|
||||
# Read plugins from stdin or from the command line arguments
|
||||
if [[ ($# -eq 0) ]]; then
|
||||
while read line; do
|
||||
plugins="${plugins:=} ${line}"
|
||||
while read -r line; do
|
||||
plugins+=("${line}")
|
||||
done
|
||||
else
|
||||
plugins="$@"
|
||||
plugins=("$@")
|
||||
fi
|
||||
|
||||
# Create lockfile manually before first run to make sure any explicit version set is used.
|
||||
echo "Creating initial locks..."
|
||||
for plugin in $plugins; do
|
||||
for plugin in "${plugins[@]}"; do
|
||||
mkdir "$(getLockFile "${plugin%%:*}")"
|
||||
done
|
||||
|
||||
|
@ -183,7 +184,7 @@ main() {
|
|||
bundledPlugins="$(bundledPlugins)"
|
||||
|
||||
echo "Downloading plugins..."
|
||||
for plugin in $plugins; do
|
||||
for plugin in "${plugins[@]}"; do
|
||||
version=""
|
||||
|
||||
if [[ $plugin =~ .*:.* ]]; then
|
||||
|
|
|
@ -54,7 +54,7 @@ then
|
|||
echo "Analyzing: $JENKINS_PLUGINS_DIR"
|
||||
for i in "$JENKINS_PLUGINS_DIR"/*/; do
|
||||
JENKINS_PLUGIN=$(basename "$i")
|
||||
JENKINS_PLUGIN_VER=$(egrep -i Plugin-Version "$i/META-INF/MANIFEST.MF"|cut -d: -f2|sed 's/ //')
|
||||
JENKINS_PLUGIN_VER=$(grep -E -i Plugin-Version "$i/META-INF/MANIFEST.MF"|cut -d: -f2|sed 's/ //')
|
||||
echo "$JENKINS_PLUGIN:$JENKINS_PLUGIN_VER"
|
||||
done >"$TEMP_ALREADY_INSTALLED"
|
||||
else
|
||||
|
@ -68,9 +68,9 @@ else
|
|||
mkdir -p "$TEMP_PLUGIN_DIR"
|
||||
PLUGIN=$(basename "$i"|cut -f1 -d'.')
|
||||
(cd "$TEMP_PLUGIN_DIR" || exit; jar xf "$JENKINS_WAR" "$i"; jar xvf "$TEMP_PLUGIN_DIR/$i" META-INF/MANIFEST.MF >/dev/null 2>&1)
|
||||
VER=$(egrep -i Plugin-Version "$TEMP_PLUGIN_DIR/META-INF/MANIFEST.MF"|cut -d: -f2|sed 's/ //')
|
||||
VER=$(grep -E -i Plugin-Version "$TEMP_PLUGIN_DIR/META-INF/MANIFEST.MF"|cut -d: -f2|sed 's/ //')
|
||||
echo "$PLUGIN:$VER"
|
||||
done 3< <(jar tf "$JENKINS_WAR" | egrep '[^detached-]plugins.*\..pi' | sort) > "$TEMP_ALREADY_INSTALLED"
|
||||
done 3< <(jar tf "$JENKINS_WAR" | grep -E '[^detached-]plugins.*\..pi' | sort) > "$TEMP_ALREADY_INSTALLED"
|
||||
rm -fr "$TEMP_PLUGIN_DIR"
|
||||
else
|
||||
rm -f "$TEMP_ALREADY_INSTALLED"
|
||||
|
@ -84,7 +84,8 @@ mkdir -p $REF
|
|||
COUNT_PLUGINS_INSTALLED=0
|
||||
while read -r spec || [ -n "$spec" ]; do
|
||||
|
||||
plugin=(${spec//:/ });
|
||||
plugin=()
|
||||
IFS=' ' read -r -a plugin <<< "${spec//:/ }"
|
||||
[[ ${plugin[0]} =~ ^# ]] && continue
|
||||
[[ ${plugin[0]} =~ ^[[:space:]]*$ ]] && continue
|
||||
[[ -z ${plugin[1]} ]] && plugin[1]="latest"
|
||||
|
|
14
publish.sh
14
publish.sh
|
@ -31,7 +31,7 @@ docker-tag() {
|
|||
|
||||
get-variant() {
|
||||
local branch
|
||||
branch=$(git show-ref | grep $(git rev-list -n 1 HEAD) | tail -1 | rev | cut -d/ -f 1 | rev)
|
||||
branch=$(git show-ref | grep "$(git rev-list -n 1 HEAD)" | tail -1 | rev | cut -d/ -f 1 | rev)
|
||||
if [ -z "$branch" ]; then
|
||||
>&2 echo "Could not get the current branch name for commit, not in a branch?: $(git rev-list -n 1 HEAD)"
|
||||
return 1
|
||||
|
@ -44,7 +44,7 @@ get-variant() {
|
|||
|
||||
login-token() {
|
||||
# could use jq .token
|
||||
curl -q -sSL https://auth.docker.io/token\?service\=registry.docker.io\&scope\=repository:jenkinsci/jenkins:pull | grep -o '"token":"[^"]*"' | cut -d':' -f 2 | xargs echo
|
||||
curl -q -sSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:jenkinsci/jenkins:pull" | grep -o '"token":"[^"]*"' | cut -d':' -f 2 | xargs echo
|
||||
}
|
||||
|
||||
is-published() {
|
||||
|
@ -71,7 +71,7 @@ get-digest() {
|
|||
}
|
||||
|
||||
get-latest-versions() {
|
||||
curl -q -fsSL https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml | grep '<version>.*</version>' | egrep -o '[0-9]+(\.[0-9]+)+' | sort-versions | uniq | tail -n 20
|
||||
curl -q -fsSL https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-war/maven-metadata.xml | grep '<version>.*</version>' | grep -E -o '[0-9]+(\.[0-9]+)+' | sort-versions | uniq | tail -n 20
|
||||
}
|
||||
|
||||
publish() {
|
||||
|
@ -79,12 +79,10 @@ publish() {
|
|||
local variant=$2
|
||||
local tag="${version}${variant}"
|
||||
local sha
|
||||
local build_opts="--no-cache --pull"
|
||||
local build_opts=(--no-cache --pull)
|
||||
|
||||
if [ "$dry_run" = true ]; then
|
||||
build_opts=""
|
||||
else
|
||||
build_opts="--no-cache --pull"
|
||||
build_opts=()
|
||||
fi
|
||||
|
||||
local dir=war
|
||||
|
@ -96,7 +94,7 @@ publish() {
|
|||
|
||||
docker build --build-arg "JENKINS_VERSION=$version" \
|
||||
--build-arg "JENKINS_SHA=$sha" \
|
||||
--tag "jenkinsci/jenkins:${tag}" ${build_opts} .
|
||||
--tag "jenkinsci/jenkins:${tag}" "${build_opts[@]}" .
|
||||
|
||||
if [ ! "$dry_run" = true ]; then
|
||||
docker push "jenkinsci/jenkins:${tag}"
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
sha() {
|
||||
local branch=$1
|
||||
git rev-parse $branch
|
||||
git rev-parse "$branch"
|
||||
}
|
||||
|
||||
version_from_dockerfile() {
|
||||
local branch=$1
|
||||
git show $branch:Dockerfile | grep JENKINS_VERSION: | sed -e 's/.*:-\(.*\)}/\1/'
|
||||
git show "$branch:Dockerfile" | grep JENKINS_VERSION: | sed -e 's/.*:-\(.*\)}/\1/'
|
||||
}
|
||||
|
||||
master_sha=$(sha master)
|
||||
|
|
Loading…
Reference in New Issue