For a previous project I used github with github actions to analyse my code with sonarcloud. Now I am trying to do the same on gitlab. but the gitlab docker runner prevents me from both building and setting my code up for analysis.
in addition to clarify: this project is made with kotlin on android sdk 22.
I have tried to make an brand new .yml script and even tried to use my github actions build.yml. the build.yml functioned a lot better but still failed.
please see this gitlab-ci.yml for further reference
stages:
- build
- analyze
variables:
ANDROID_HOME: “/sdk”
ANDROID_SDK_ROOT: “/sdk”
SONAR_TOKEN: $SONAR_TOKEN
GRADLE_USER_HOME: “$CI_PROJECT_DIR/.gradle”
before_script:
Install dependencies
- apt-get update && apt-get install -y openjdk-17-jdk wget unzip
- export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
- export PATH=$JAVA_HOME/bin:$PATH
Download and install Android SDK command line tools
- wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -O /sdk.zip
- mkdir -p $ANDROID_HOME/cmdline-tools
- unzip -q /sdk.zip -d $ANDROID_HOME/cmdline-tools
- mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest
Install required SDK components
- yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager –licenses
- yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager “platform-tools” “platforms;android-30” “build-tools;30.0.3”
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
– .gradle/
– .sonar/cache/
– /sdk
build_job:
stage: build
script:
– chmod +x ./gradlew
– ./gradlew build –info
analyze_job:
stage: analyze
script:
– ./gradlew sonar –info –exclude-task check
only:
– main
– merge_requests
user25094648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.