elleryq
3/8/2016 - 4:04 AM

jenkins-cli.jar wrapper. Download jenkins-cli.jar automatically and wrap it as command.

jenkins-cli.jar wrapper. Download jenkins-cli.jar automatically and wrap it as command.

#!/bin/bash

# To get installed plugins
jenkins-cli.sh list-plugins 2>/dev/null | awk '{if (!/^Skipping/) print $1;}'

# 2>/dev/null to ignore warnings
# "if (!/^Skipping/)" to ignore "Skipping", it is not plugin name
#!/bin/bash

JENKINS_URL="http://localhost/jenkins"
JENKINS_JAR="/tmp/jenkins-cli.jar"

SSL_CHAR=${JENKINS_URL:4:1}

if [ ! -e $JENKINS_JAR ]; then
    WGET="wget $JENKINS_URL/jnlpJars/jenkins-cli.jar -O $JENKINS_JAR"
    if [ "$SSL_CHAR" == "s"]; then
        WGET="$WGET --no-check-certificate"
    fi
fi

BASE_CMD="java -jar $JENKINS_JAR -s $JENKINS_URL/"
if [ "$SSL_CHAR" == "s" ]; then
    BASE_CMD="$BASE_CMD -noCertificateCheck"
fi
if [ -z $1 ]; then
    $BASE_CMD help
else
    $BASE_CMD $*
fi