Skip to content

Commit

Permalink
feat(sonar-action-2.0): support sonar_java_binaries option of sonar-s…
Browse files Browse the repository at this point in the history
…canner-cli
  • Loading branch information
sfwn committed Oct 22, 2024
1 parent f19b50b commit 32fb08a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
11 changes: 4 additions & 7 deletions actions/sonar/2.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$TARGETPLATFORM registry.erda.cloud/retag/golang:1.17.12-alpine3.15 AS builder
FROM --platform=$TARGETPLATFORM registry.erda.cloud/erda-x/golang:1.22 AS builder

COPY . /go/src/github.com/erda-project/erda-actions
WORKDIR /go/src/github.com/erda-project/erda-actions
Expand All @@ -7,20 +7,17 @@ ARG ARCH

RUN GOOS=linux GOARCH=$ARCH go build -o /assets/run actions/sonar/2.0/internal/cmd/*.go

FROM --platform=$TARGETPLATFORM registry.erda.cloud/erda/terminus-centos:base AS action
FROM --platform=$TARGETPLATFORM registry.erda.cloud/erda-x/golang:1.22 AS action

RUN yum install -y wget unzip
RUN apt install -y wget unzip

RUN mkdir /opt/sonarqube && cd /opt/sonarqube && \
wget https://terminus-dice.oss-cn-hangzhou.aliyuncs.com/sonarqube/scanner/sonar-scanner-cli-4.4.0.2170-linux.zip && \
unzip -q sonar-scanner-cli-4.4.0.2170-linux.zip

# nodejs
# https://docs.sonarqube.org/latest/analysis/languages/javascript/
ENV NODE_VERSION 16.16.0
RUN \
curl --silent --location https://rpm.nodesource.com/setup_16.x | bash - && \
yum install -y nodejs-$NODE_VERSION
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash - && apt update && apt install -y nodejs && rm -fr /var/lib/apt/lists/*
# typescript
RUN npm install -g typescript
ENV NODE_PATH "/usr/lib/node_modules/"
Expand Down
2 changes: 1 addition & 1 deletion actions/sonar/2.0/dice.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### job 配置项
jobs:
sonar:
image: registry.erda.cloud/erda-actions/sonar-action:2.0-20221028110957-495a113
image: registry.erda.cloud/erda-actions/sonar-action:2.0-20241022174835-f19b50b
resources:
cpu: 1
mem: 2048
Expand Down
4 changes: 4 additions & 0 deletions actions/sonar/2.0/internal/pkg/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type ActionParams struct {
// +optional
ProjectKey string `env:"ACTION_SONAR_PROJECT_KEY"`

// Java
// +optional
SonarJavaBinaries string `env:"ACTION_SONAR_JAVA_BINARIES"`

MustGateStatusOK bool `env:"ACTION_MUST_GATE_STATUS_OK"`
}

Expand Down
5 changes: 5 additions & 0 deletions actions/sonar/2.0/internal/pkg/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func (s *Sonar) Execute() error {
s.cmd.Add(fmt.Sprintf("-Dsonar.password=%s", s.cfg.SonarPassword))
}

// java
if s.cfg.SonarJavaBinaries != "" {
s.cmd.Add(fmt.Sprintf("-Dsonar.java.binaries=%s", s.cfg.SonarJavaBinaries))
}

projectKey := s.cfg.ProjectKey
if projectKey == "" {
return fmt.Errorf("missing project key")
Expand Down

0 comments on commit 32fb08a

Please sign in to comment.