Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Gitlab Tutorials: CI for automation and .Net Framework Sonarqube Codecoverage


variables:
  SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
  GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task

stages:
  - build
  - test
  - analyze

before_script:
 - Set-Variable -Name "time" -Value (Get-Date -Format "%H:%m")
 - echo ${time}
 - echo "started by ${GITLAB_USER_NAME}"



build:
  stage: build
  only:
    - branches
  script:
    - echo "running scripts in the build job"
    - choco feature enable -n=allowGlobalConfirmation
    - choco install netfx-4.6.2-devpack
    - choco install dotnetcore-sdk
    - nuget restore -ConfigFile .\nuget.config 
    - msbuild ".\ProcessFlowModuleDotNetV1\ProcessFlowModule.csproj" /p:DeployOnBuild=true /p:PublishProfile="Local Publish" /p:WarningLevel=0
    - dotnet build ".\ProcessFlowModuleDotNetV1.Tests\ProcessFlowModule.Tests.csproj" --configuration Release
  artifacts:
    paths:
      - Publish
      - .\ProcessFlowModule.Tests\bin\Release\netcoreapp3.1\**
      - .\ProcessFlowModule
    expire_in: 1 day
  after_script:
    - Remove-Item -Recurse -Force .\packages\


sonarcloud-check:
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  dependencies:
    - build
  script:    
    - SonarScanner.MSBuild.exe begin /k:"project_key" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="jjhyd8b6500d75a8af6f7c3a3726a2b8782a39a439a7"   
    - nuget restore -ConfigFile .\nuget.config
    - MsBuild.exe ./ProcessFlowModule /t:Rebuild
    - SonarScanner.MSBuild.exe end /d:sonar.login="jjhyd8b6500d75a8af6f7c3a3726a2b8782a39a439a7"
  only:
    - branches

Here I try with default script:
    sonarcloud-check:
  stage: test
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - sonar-scanner

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x