diff --git a/actions/sonar/2.0/Dockerfile b/actions/sonar/2.0/Dockerfile index 91fc6408..02185eb3 100644 --- a/actions/sonar/2.0/Dockerfile +++ b/actions/sonar/2.0/Dockerfile @@ -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 @@ -7,9 +7,9 @@ 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 && \ @@ -17,10 +17,7 @@ RUN mkdir /opt/sonarqube && cd /opt/sonarqube && \ # 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/" diff --git a/actions/sonar/2.0/dice.yml b/actions/sonar/2.0/dice.yml index 626b994e..e494ebc4 100644 --- a/actions/sonar/2.0/dice.yml +++ b/actions/sonar/2.0/dice.yml @@ -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 diff --git a/actions/sonar/2.0/internal/pkg/conf.go b/actions/sonar/2.0/internal/pkg/conf.go index 22fc7c14..7c51e1fb 100644 --- a/actions/sonar/2.0/internal/pkg/conf.go +++ b/actions/sonar/2.0/internal/pkg/conf.go @@ -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"` } diff --git a/actions/sonar/2.0/internal/pkg/execute.go b/actions/sonar/2.0/internal/pkg/execute.go index 6968131e..1da3636e 100644 --- a/actions/sonar/2.0/internal/pkg/execute.go +++ b/actions/sonar/2.0/internal/pkg/execute.go @@ -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")