From 79f06d4e4c9b02f215012320448f928830c1cea1 Mon Sep 17 00:00:00 2001 From: SoXX Date: Fri, 19 Jul 2024 11:13:30 +0200 Subject: [PATCH] ci: added initial Jenkinsfile --- .gitea/workflows/build_check.yaml | 39 ------------------------------- Jenkinsfile | 33 ++++++++++++++++++++++++++ sonar-project.properties | 1 + 3 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 .gitea/workflows/build_check.yaml create mode 100644 Jenkinsfile create mode 100644 sonar-project.properties diff --git a/.gitea/workflows/build_check.yaml b/.gitea/workflows/build_check.yaml deleted file mode 100644 index 7120eae..0000000 --- a/.gitea/workflows/build_check.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Gitea Build Check -run-name: ${{ gitea.actor }} is testing the build -on: - push: - branches: - - main - pull_request: - branches: [ "main" ] - -jobs: - Build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - - name: Setup Go environment - uses: https://github.com/actions/setup-go@v5 - with: - # The Go version to download (if necessary) and use. Supports semver spec and ranges. - go-version: 1.22.0 # optional - # Path to the go.mod file. - go-version-file: ./go.mod # optional - # Set this option to true if you want the action to always check for the latest available version that satisfies the version spec - check-latest: true # optional - # Used to specify whether caching is needed. Set to true, if you'd like to enable caching. - cache: true # optional - - - name: Execute Go Test files with coverage report - run: TESTCONTAINERS_RYUK_DISABLED=true go test -v ./... -json -coverprofile="coverage.out" | tee "test-report.out" - - - uses: sonarsource/sonarqube-scan-action@master - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }} - with: - args: > - -Dsonar.projectKey=Anthrove---OtterSpace-SDK \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..48b4ff3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,33 @@ +pipeline { + agent { + docker { image 'docker:dind' } + } + tools { + dockerTool 'Docker' + } + stages { + stage('Checkout') { + steps { + checkout scm + } + } + stage('Go Test') { + agent { + docker { image 'golang:1.22-alpine' } + } + steps { + sh 'go test -v ./... -json -coverprofile=coverage.out > test-report.out' + } + } + stage('SonarQube Analysis') { + agent { + docker { image 'amazoncorretto:22-alpine' } + } + def scannerHome = tool 'SonarScanner' + withSonarQubeEnv() { + sh "${scannerHome}/bin/sonar-scanner" + } + } + } +} + diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..95bc929 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1 @@ +sonar.projectKey=Anthrove---OtterSpace-SDK \ No newline at end of file