본문 바로가기
카테고리 없음

🥰 argo workflow sonar scanner C# sample

by Knowledge Store In Hyunsoft 2024. 8. 27.

 

  • argo workflowTemplete sonar scanner C# sample
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: sonarscanner-csharp-template
spec:
  entrypoint: sonar-scanner-csharp
  templates:
    - name: sonar-scanner-csharp
      steps:
        - - name: clone-repo
            template: git-clone

          - name: restore-dotnet-dependencies
            template: restore-dependencies

          - name: build-project
            template: build-project

          - name: run-sonar-scanner
            template: run-sonar-scanner

    - name: git-clone
      container:
        image: alpine/git:latest
        command: [sh, -c]
        args: [
          'git clone https://github.com/your-repo-url.git /src && cd /src'
        ]
        volumeMounts:
          - name: workdir
            mountPath: /src

    - name: restore-dependencies
      container:
        image: mcr.microsoft.com/dotnet/sdk:7.0
        command: [sh, -c]
        args: [
          'cd /src && dotnet restore'
        ]
        volumeMounts:
          - name: workdir
            mountPath: /src

    - name: build-project
      container:
        image: mcr.microsoft.com/dotnet/sdk:7.0
        command: [sh, -c]
        args: [
          'cd /src && dotnet build --no-restore'
        ]
        volumeMounts:
          - name: workdir
            mountPath: /src

    - name: run-sonar-scanner
      container:
        image: sonarsource/sonar-scanner-cli:latest
        command: [sh, -c]
        args: [
          'cd /src && sonar-scanner -Dsonar.projectKey=your-project-key -Dsonar.host.url=https://your-sonar-server -Dsonar.login=$SONAR_TOKEN'
        ]
        env:
          - name: SONAR_TOKEN
            valueFrom:
              secretKeyRef:
                name: sonar-secret
                key: sonar-token
        volumeMounts:
          - name: workdir
            mountPath: /src

  volumes:
    - name: workdir
      emptyDir: {}

 

argo workflow

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: sonar-scanner-csharp-run-
spec:
  workflowTemplateRef:
    name: sonarscanner-csharp-template
728x90

댓글