From 0fdb63a1321321658b4e642edbb31cdb9969ee2d Mon Sep 17 00:00:00 2001 From: Ravindra Bhadti Date: Wed, 15 Sep 2021 17:49:19 +0100 Subject: [PATCH] GH-18 Adding In JMeter Plugin Capability (#19) * GH-18 adding in gitignore and jmeter plugins * GH-18 adding in gitignore and jmeter plugins * GH-18 adding in gitignore and jmeter plugins * feature/gh-18 jmeter-plugins (#20) Adding in plugin capabilities Co-authored-by: Michael Meyers --- .gitignore | 1 + Dockerfile | 15 ++++++++++++--- action.yaml | 11 +++++++++++ cleanup.sh | 2 ++ entrypoint.sh | 14 +++++++++++++- 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100755 cleanup.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 25559af..ea71170 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,17 +8,26 @@ ENV JMETER_VERSION "5.4.1" ENV JMETER_HOME "/opt/apache/apache-jmeter-${JMETER_VERSION}" ENV JMETER_BIN "${JMETER_HOME}/bin" ENV PATH "$PATH:$JMETER_BIN" +ENV CMD_RUNNER_VERSION 2.2 +ENV JMETER_PLUGIN_VERSION 1.6 +ENV MAVEN_REPO "https://repo1.maven.org/maven2/kg/apc" COPY entrypoint.sh /entrypoint.sh +COPY cleanup.sh /cleanup.sh -RUN apk --no-cache add curl ca-certificates openjdk9-jre && \ +RUN apk --no-cache add curl ca-certificates openjdk9-jre parallel && \ curl -L https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-${JMETER_VERSION}.tgz --output /tmp/apache-jmeter-${JMETER_VERSION}.tgz && \ - tar -zxvf /tmp/apache-jmeter-${JMETER_VERSION}.tgz && \ + tar -zxf /tmp/apache-jmeter-${JMETER_VERSION}.tgz && \ mkdir -p /opt/apache && \ mv apache-jmeter-${JMETER_VERSION} /opt/apache && \ rm /tmp/apache-jmeter-${JMETER_VERSION}.tgz && \ + curl ${MAVEN_REPO}/cmdrunner/${CMD_RUNNER_VERSION}/cmdrunner-${CMD_RUNNER_VERSION}.jar --output ${JMETER_HOME}/lib/cmdrunner-${CMD_RUNNER_VERSION}.jar && \ + curl ${MAVEN_REPO}/jmeter-plugins-manager/${JMETER_PLUGIN_VERSION}/jmeter-plugins-manager-${JMETER_PLUGIN_VERSION}.jar --output ${JMETER_HOME}/lib/ext/jmeter-plugins-manager-${JMETER_PLUGIN_VERSION}.jar && \ + java -cp ${JMETER_HOME}/lib/ext/jmeter-plugins-manager-${JMETER_PLUGIN_VERSION}.jar org.jmeterplugins.repository.PluginManagerCMDInstaller && \ + chmod +x ${JMETER_HOME}/bin/PluginsManagerCMD.sh && \ rm -rf ${JMETER_HOME}/docs && rm -rf ${JMETER_HOME}/printable_docs \ rm -rf /var/cache/apk/* && \ - chmod a+x /entrypoint.sh + chmod a+x /entrypoint.sh && \ + chmod a+x /cleanup.sh ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/action.yaml b/action.yaml index e35dfc6..3257ff6 100644 --- a/action.yaml +++ b/action.yaml @@ -11,6 +11,12 @@ inputs: description: The folder where the JMeter reports will be published required: false default: reports/ + plugins: + description: List of jmeter plugins to install + required: false + dependencyFolder: + description: Folder that contains custom jmeter plugins or dependencies + required: false args: required: false description: | @@ -46,6 +52,11 @@ inputs: runs: using: 'docker' image: 'Dockerfile' + post-entrypoint: '/cleanup.sh' + env: + PLUGINS: ${{ inputs.plugins }} + DEPENDENCY_FOLDER: ${{ inputs.dependencyFolder }} + REPORT_FOLDER: ${{ inputs.outputReportsFolder }} args: - "-n" - "-t" diff --git a/cleanup.sh b/cleanup.sh new file mode 100755 index 0000000..1ec7aac --- /dev/null +++ b/cleanup.sh @@ -0,0 +1,2 @@ +#!/bin/sh +rm -rf ${REPORT_FOLDER} diff --git a/entrypoint.sh b/entrypoint.sh index c378c49..cd5a539 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,4 +3,16 @@ # Export JAVA_HOME Variable within Entrypoint export JAVA_HOME="/usr/lib/jvm/java-9-openjdk" -jmeter $@ \ No newline at end of file +if [ -n "$DEPENDENCY_FOLDER" ] +then + cp ${GITHUB_WORKSPACE}/${DEPENDENCY_FOLDER}/*.jar ${JMETER_HOME}/lib/ +fi + +if [ -n "$PLUGINS" ] +then + echo "$PLUGINS" | tr "," "\n" | parallel -I% --jobs 5 "${JMETER_HOME}/bin/PluginsManagerCMD.sh install %" +fi + +jmeter $@ +status=$? +[ $status -eq 0 ] && exit 0 || echo "JMeter exited with status code $status" && exit $status