diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..3fb7dee --- /dev/null +++ b/.drone.yml @@ -0,0 +1,66 @@ +kind: pipeline +type: docker +name: analyseAndBuild + +steps: + - name: buildAndTest + image: gradle:jdk8 + commands: + - ./gradlew build + - ./gradlew test + - name: analyse + image: maven:3-jdk-11 + failure: ignore + commands: + - ./gradlew sonarqube -Dsonar.projectKey=cv-api -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN + environment: + SONAR_HOST_URL: + from_secret: sonarScannerHostUrl + SONAR_LOGIN: + from_secret: sonarScannerLogin +trigger: + event: + - push + - pull_request +--- +kind: pipeline +type: docker +name: Deploy + +steps: + - name: build + image: gradle:jdk8 + commands: + - ./gradlew assemble + - name: scpFiles + image: appleboy/drone-scp + settings: + host: amine-louveau.fr + username: ubuntu + key: + from_secret: privateKey + port: 22 + target: /home/ubuntu/cv-api + source: build/libs/* + - name: deploy + image: appleboy/drone-ssh + settings: + host: amine-louveau.fr + user: ubuntu + key: + from_secret: privateKey + command_timeout: 2m + script: + - sudo service cv-api stop + - cd /home/ubuntu/cv-api + - sudo chown ubuntu:ubuntu ./* + - sudo mv -f ./cvApi-1.0-SNAPSHOT.jar /usr/local/bin/ #todo change file to variable + - cd /usr/local/bin/ + - sudo mv cv-api.jar cv-api.jar.back + - sudo ln -s cvApi-1.0-SNAPSHOT.jar cv-api.jar #todo change file to variable + - sudo service cv-api start +trigger: + event: + - promote + target: + - production \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index ad51072..f5a3b14 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("com.squareup.sqldelight") + id("org.sonarqube") kotlin("jvm") version "1.7.10" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 645c50b..4c7a6f1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,6 +12,9 @@ pluginManagement { if (requested.id.id == "com.squareup.sqldelight") { useModule("com.squareup.sqldelight:gradle-plugin:1.5.3") } + if (requested.id.id == "org.sonarqube") { + useModule("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.4.0.2513") + } } } }