Repo-Swap and Build

pull/1/head
gapodo 2022-10-30 20:29:33 +01:00
parent 6e5243f405
commit 060bfbd89a
9 changed files with 114 additions and 10 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
*
!go.mod
!go.sum
!cmd
!pkg

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
woodpecker-plugin-sonar
plugin-sonar
.scannerwork

50
.woodpecker/build.yaml Normal file
View File

@ -0,0 +1,50 @@
pipeline:
debug:
image: busybox
commands:
- env
sonar-tests:
image: git.kle.li/woodpecker/plugin-sonar:manual
settings:
sonar_url: https://sonar.kle.li
sonar_token:
from_secret: sonar_token
sonar_key: ${CI_REPO_OWNER}:${CI_REPO_NAME}
sonar_quality_enabled: true
branchanalysis: auto
publish-docker-image:
image: woodpeckerci/plugin-docker-buildx
settings:
repo: git.kle.li/${CI_REPO}
platforms: linux/amd64
tag: ${CI_COMMIT_BRANCH}
dockerfile: Dockerfile
registry: git.kle.li
username:
from_secret: gitea_user
password:
from_secret: gitea_token
when:
branch: [main, test, dev, release/*]
path:
exclude: ["*.md", "docs/**"]
ignore_message: "[FORCE CI]"
publish-docker-tag-image:
image: woodpeckerci/plugin-docker-buildx
settings:
repo: git.kle.li/${CI_REPO}
platforms: linux/amd64
tag: ${CI_COMMIT_TAG},
dockerfile: Dockerfile
registry: git.kle.li
username:
from_secret: gitea_user
password:
from_secret: gitea_token
when:
tag: v*
path:
exclude: ["*.md", "docs/**"]
ignore_message: "[FORCE CI]"

46
Dockerfile Normal file
View File

@ -0,0 +1,46 @@
FROM golang:1.19-alpine as go-build
ARG GO_WORK="/go/src/git.kle.li/woodpecker/plugin-sonar"
RUN mkdir -p "${GO_WORK}"
WORKDIR "${GO_WORK}"
COPY ./ "${GO_WORK}/"
RUN go mod download \
&& go mod verify \
&& go build -o /plugin-sonar ./cmd/main.go
FROM alpine:latest as sonar-prep
ARG SONAR_VERSION=4.7.0.2747
ARG SONAR_SCANNER_CLI=sonar-scanner-cli-${SONAR_VERSION}
ARG SONAR_SCANNER=sonar-scanner-${SONAR_VERSION}
WORKDIR "/sonar"
RUN apk add --no-cache --update curl unzip
RUN curl https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/${SONAR_SCANNER_CLI}.zip -so "/sonar/${SONAR_SCANNER_CLI}.zip" \
&& unzip "${SONAR_SCANNER_CLI}.zip" \
&& rm "${SONAR_SCANNER_CLI}.zip" \
&& pwd && ls -la \
&& mv "${SONAR_SCANNER}" "/sonar/sonar-scanner" \
&& echo "${SONAR_VERSION}" > "/sonar/sonar-scanner/version"
FROM alpine:latest
# set / add low change items
WORKDIR /bin
RUN apk add --no-cache --update nodejs npm && rm -rf /var/cache/apk/*
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:17-jre-alpine $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"
# add plugin binary
RUN echo "/plugin-sonar $SONAR_SCANNER"
COPY --from=go-build "/plugin-sonar" /bin/
# add sonar download
COPY --from=sonar-prep "/sonar" /bin/
ENV PATH $PATH:/bin/sonar-scanner/bin
ENTRYPOINT [ "/bin/plugin-sonar" ]

View File

@ -20,9 +20,9 @@ import (
"os"
"time"
plugLib "git.kle.li/gapodo/woodpecker-plugin-lib/urfave"
"git.kle.li/gapodo/woodpecker-plugin-sonar/pkg/plugin"
"git.kle.li/gapodo/woodpecker-plugin-sonar/pkg/sonar"
plugLib "git.kle.li/woodpecker/plugin-lib/urfave"
"git.kle.li/woodpecker/plugin-sonar/pkg/plugin"
"git.kle.li/woodpecker/plugin-sonar/pkg/sonar"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)
@ -41,7 +41,7 @@ func main() {
Email: "gapodo@geekvoid.net",
},
},
Copyright: "(c) 2022 Michael Amann",
Copyright: "(c) 2022 Woodpecker Authors",
Before: func(ctx *cli.Context) error {
fmt.Fprintf(ctx.App.Writer, "Woodpecker-CI SonarQube plugin\n")
return nil

4
go.mod
View File

@ -1,9 +1,9 @@
module git.kle.li/gapodo/woodpecker-plugin-sonar
module git.kle.li/woodpecker/plugin-sonar
go 1.19
require (
git.kle.li/gapodo/woodpecker-plugin-lib v0.0.4
git.kle.li/woodpecker/plugin-lib v0.0.5
github.com/pelletier/go-toml v1.9.5
github.com/urfave/cli/v2 v2.20.3
go.uber.org/zap v1.23.0

4
go.sum
View File

@ -1,5 +1,5 @@
git.kle.li/gapodo/woodpecker-plugin-lib v0.0.4 h1:+N8ZKk7NkpnCb3/nNTJwM8rjGlK1Wzi4uLzN7HY+wZM=
git.kle.li/gapodo/woodpecker-plugin-lib v0.0.4/go.mod h1:HcNuDYsML3ZwNi/pYrgpzwEqkV/e+sC2eaPpaLmmBLQ=
git.kle.li/woodpecker/plugin-lib v0.0.5 h1:sZXGK/zRB83YQu75b3zkh47svRwTWKUccV2jER8Sq7U=
git.kle.li/woodpecker/plugin-lib v0.0.5/go.mod h1:vzLk04kVG43eMrJjPIvFBE42UuG9QttZIXUm6HB5LUA=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=

View File

@ -21,8 +21,8 @@ import (
"strconv"
"strings"
"git.kle.li/gapodo/woodpecker-plugin-lib/common"
"git.kle.li/gapodo/woodpecker-plugin-sonar/pkg/sonar"
"git.kle.li/woodpecker/plugin-lib/common"
"git.kle.li/woodpecker/plugin-sonar/pkg/sonar"
"github.com/pelletier/go-toml"
"go.uber.org/zap"
)

Binary file not shown.