diff --git a/.gitignore b/.gitignore index 502cd67..5b1a92d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .vscode/launch.json sonarlint.json + +\.sonar/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..dc4f871 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +sudo: required +dist: trusty +addons: + sonarcloud: true +jdk: + - oraclejdk8 +before_install: + - chmod +x travis.sh +cache: + directories: + - '$HOME/.m2/repository' + - '$HOME/.sonar/cache' +script: + - ./travis.sh \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..97f34cb --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,19 @@ +# must be unique in a given SonarQube instance +sonar.projectKey=opensource-irac + +# this is the name displayed in the SonarQube UI +sonar.projectName=opensource-irac + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +# Since SonarQube 4.2, this property is optional if sonar.modules is set. +# If not set, SonarQube starts looking for source code from the directory containing +# the sonar-project.properties file. + +sonar.sources=./src + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 + +sonar.organization=sonar-opensource-add + +# sonar.coverageReportPaths=coverage/genericCoverage.xml \ No newline at end of file diff --git a/travis.sh b/travis.sh new file mode 100644 index 0000000..ef931d2 --- /dev/null +++ b/travis.sh @@ -0,0 +1,28 @@ + +#!/bin/bash +set -e + +# oscript /usr/share/oscript/lib/opm/src/opm.os run coverage + +temp=`cat packagedef | grep ".Версия(" | sed 's|[^"]*"||' | sed -r 's/".+//'` +version=${temp##*|} + +if [ "$TRAVIS_SECURE_ENV_VARS" == "true" ]; then + if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + sonar-scanner \ + -Dsonar.host.url=https://sonar.silverbulleters.org \ + -Dsonar.analysis.mode=issues \ + -Dsonar.github.pullRequest=$TRAVIS_PULL_REQUEST \ + -Dsonar.github.repository=$TRAVIS_REPO_SLUG \ + -Dsonar.github.oauth=$SONAR_GITHUB_TOKEN \ + -Dsonar.login=$SONAR_TOKEN \ + -Dsonar.scanner.skip=false + + elif [ "$TRAVIS_BRANCH" == "develop" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + sonar-scanner \ + -Dsonar.host.url=https://sonar.silverbulleters.org \ + -Dsonar.login=$SONAR_TOKEN \ + -Dsonar.projectVersion=$version\ + -Dsonar.scanner.skip=false + fi +fi \ No newline at end of file