From cc7d4eeb716b364f851d7e61f4cc294105bc3f0b Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Wed, 7 Aug 2024 13:56:32 +0200 Subject: [PATCH] feat: initial version - just uploading files --- Containerfile | 21 +++++++++++++++++++++ plugin.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Containerfile create mode 100644 plugin.sh diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..0e333fc --- /dev/null +++ b/Containerfile @@ -0,0 +1,21 @@ +FROM alpine as builder + +RUN apk update && apk add --no-cache git openssl openssl-dev make alpine-sdk cmake musl-dev linux-headers + +WORKDIR /src + +RUN git clone --recurse-submodules https://gitea.federationhq.de/byterazor/redmine-api-cpp.git + +RUN cd redmine-api-cpp && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=OFF && make -j 4 + +FROM alpine:latest + +RUN apk update && apk add --no-cache tini bash ca-certificates openssl libgcc libstdc++ libcurl coreutils + +COPY --from=builder /src/redmine-api-cpp/build/redmine-cli /usr/local/bin/redmine-cli + +ADD plugin.sh / +RUN chmod a+x /plugin.sh + + +ENTRYPOINT ["/sbin/tini", "--", "/plugin.sh"] \ No newline at end of file diff --git a/plugin.sh b/plugin.sh new file mode 100644 index 0000000..276b7a4 --- /dev/null +++ b/plugin.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. +# + +if [ -z ${PLUGIN_REDMINE_URL} ]; then + echo "ERROR: Please set REDMINE_URL" + exit -1 +fi + +if [ -z ${PLUGIN_REDMINE_TOKEN} ]; then + echo "ERROR: Please set REDMINE_TOKEN" + exit -1 +fi + +if [ -z ${PLUGIN_PROJECT_ID} ]; then + echo "ERROR: Please set PROJECT_ID" + exit -1 +fi + +export REDMINE_URL=$PLUGIN_REDMINE_URL +export REDMINE_TOKEN=$PLUGIN_REDMINE_TOKEN + +if [ -n ${PLUGIN_UPLOAD_FILES} ]; then + + if [ "${PLUGIN_UPLOAD_FILES}" == "true" ]; then + for f in $PLUGIN_FILES; do + FPATH=$(echo $f | cut -d ':' -f 1) + NAME=$(echo $f | cut -d ':' -f 2) + DESC=$(echo $f | cut -d ':' -f 3) + VERS=$(echo $f | cut -d ':' -f 4) + + redmine-cli project upload -p ${PLUGIN_PROJECT_ID} -f ${NAME} -d ${DESC} -v ${VERS} $FPATH + done + fi +fi \ No newline at end of file