0

I am trying to integrate Sonarqube into my project CI/CD pipeline on Gitlab. I have followed the documentation on Gitlab and Sonarqube to the best of my understanding to get the job included in my yml file.

I am current experiencing the error as shown in the image below enter image description here

This is my yml file script

build_project:
  stage: build
  script:
    - xcodebuild clean -workspace TinggIOS/TinggIOS.xcworkspace -scheme TinggIOS | xcpretty
    - xcodebuild test -workspace TinggIOS/TinggIOS.xcworkspace -scheme TinggIOS -destination 'platform=iOS Simulator,name=iPhone 11 Pro Max,OS=15' | xcpretty -s
  tags:
    - stage
  image: macos-11-xcode-12

sonarqube-check:
  stage: analyze
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  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
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - sonar-scanner -Dsonar.qualitygate.wait=true
  allow_failure: true
  only:
    - merge_requests
    - feature/unit-test # or the name of your main branch
    - develop
  tags:
    - stage
Darotudeen
  • 1,914
  • 4
  • 21
  • 36

1 Answers1

1

It looks like the

- sonar-scanner -Dsonar.qualitygate.wait=true

command is not found. Try to run that command on the machine you are setting up your pipeline (like ssh into that machine or ssh into it and try running that command). The issue might be that it isn't installed on there.

  • Thanks this helped. I was able to use docker to run it eventually. – Darotudeen Aug 11 '22 at 09:32
  • Do you have an idea how I can export the code coverage from Xcode to Sonarqube? – Darotudeen Aug 11 '22 at 09:32
  • That is pretty easy. Look into the `xcrun` tool `xccov`. You need to make sure you have appropriate flags settings when you set it up. Things like `xcrun xccov view YourPathToThisFile/*.xccovreport --json` if you want all data in JSON format and ect... – Jon_the_developer Aug 11 '22 at 15:51
  • I get this error "This version of Xcode does not support opening result bundles created with versions of Xcode and xcodebuild using the v1 API" and also does not allow --xml – Darotudeen Aug 11 '22 at 19:31
  • https://stackoverflow.com/questions/61544415/unable-to-export-test-result-in-xcode-11-4 Honestly I have yet to have any issues with xccov. Though I have only used it with Jenkins. – Jon_the_developer Aug 11 '22 at 19:42