diff --git a/.workflow/01_container_build.sh b/.workflow/01_container_build.sh index 2b74a15..91b1408 100644 --- a/.workflow/01_container_build.sh +++ b/.workflow/01_container_build.sh @@ -4,18 +4,31 @@ echo "USER: $UID" # Parse owner/repo from GIT_URL : "${GIT_URL:?Missing GIT_URL in Jenkins env}" +# GIT_URL="https://gitea.a.ucnit.eu/DMA-CSD-CICD/Test01.git" # Handle formats: https://gitea.example.com/owner/repo.git or git@gitea.example.com:owner/repo.git OWNER="" REPO="" -if [[ "$GIT_URL" =~ [:\/]([^\/:]+)\/([^\/\.]+)(\.git)?$ ]]; then - OWNER="${BASH_REMATCH[1]}" - REPO="${BASH_REMATCH[2]}" +GIT="" +if echo "$GIT_URL" | grep -q "^http"; then + GIT=$(echo "$GIT_URL" | cut -f 3 -d '/') + OWNER=$(echo "$GIT_URL" | cut -f 4 -d '/') + REPO=$(echo "$GIT_URL" | cut -f 5 -d '/' | xargs -- basename -s .git) fi +if echo "$GIT_URL" | grep -q "^git@"; then + GIT=$(echo "$GIT_URL" | cut -f 2 -d '@' | cut -f 1 -d ':') + OWNER=$(echo "$GIT_URL" | cut -f 2 -d ':' | cut -f 1 -d '/') + REPO=$(echo "$GIT_URL" | cut -f 2 -d '/' | xargs -- basename -s .git) +fi + +# if [[ "$GIT_URL" =~ [:\/]([^\/:]+)\/([^\/\.]+)(\.git)?$ ]]; then + # OWNER="${BASH_REMATCH[1]}" + # REPO="${BASH_REMATCH[2]}" +# fi if [[ -z "$OWNER" || -z "$REPO" ]]; then echo "[ERROR] Could not determine owner/repo from GIT_URL=$GIT_URL" exit 1 fi -echo "Will publish package at [$OWNER]" +echo "Will publish package at [$REPO]/[$OWNER]" echo "Will build:" /bin/find ./ -type f -name "*.csproj" | while read line; do @@ -29,6 +42,6 @@ done solution=$(echo "$line" | cut -f 2 -d '/') project=$(echo "$line" | cut -f 3 -d '/') echo "Building [$solution] [$project]" - .workflow/DotDockerbuilder10.sh --solution $solution --project $project --gituser $OWNER + .workflow/DotDockerbuilder10.sh --solution $solution --project $project --git $GIT --gituser $OWNER done diff --git a/.workflow/DotDockerbuilder10.sh b/.workflow/DotDockerbuilder10.sh index 2e018d6..faff7db 100644 --- a/.workflow/DotDockerbuilder10.sh +++ b/.workflow/DotDockerbuilder10.sh @@ -199,6 +199,8 @@ if [ -n "$Git" ]; then echo "Cleaning up: [$tagName:latest] [$CONTAINERNAME:latest] [$CONTAINERNAME:$(date +%y%m%d)]" sudo docker image rm $tagName:latest sudo docker image rm $CONTAINERNAME:latest $CONTAINERNAME:$(date +%y%m%d) +else + echo "Not pushing to package repository as Git[$Git] or GitUser[$GitUser] is blank" fi sudo docker image prune --force diff --git a/README.md b/README.md index 4a475cb..e493af8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # KAJE-Template -Template repository \ No newline at end of file +Template repository + +## Special branches +- Docker changes here will cause container creation +- Security changes here will cause AI security check \ No newline at end of file