From 541f7bfe602b8982a3107322b15a1c206fc90cca Mon Sep 17 00:00:00 2001
From: Daya Adianto <dayaadianto@cs.ui.ac.id>
Date: Fri, 6 Sep 2019 21:12:25 +0700
Subject: [PATCH] Create GitLab CI/CD configuration

---
 .gitlab-ci.yml           | 30 ++++++++++++++++++++++++++++++
 sonar-project.properties | 16 ++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 sonar-project.properties

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..f93825a
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,30 @@
+---
+image: docker:19
+stages:
+  - test
+  - deploy
+
+SonarScanner Analysis:
+  image: addianto/sonar-scanner-cli:latest
+  stage: test
+  script:
+    - sonar-scanner
+      -Dsonar.host.url=$SONARQUBE_HOST
+      -Dsonar.login=$SONARQUBE_TOKEN
+  only:
+    - master
+
+Publish to Docker Hub:
+  stage: deploy
+  before_script:
+    - chmod +x build.sh
+  script:
+    - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
+    - ./build.sh $IMAGE_NAMESPACE
+    - docker push "$IMAGE_NAMESPACE/sonar-scanner-cli:latest"
+  when: manual
+  allow_failure: true
+  tags:
+    - docker
+  only:
+    - master
\ No newline at end of file
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 0000000..6154ca5
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,16 @@
+# SonarScanner Properties
+
+## Server
+### sonar.host.url=[pass URL via CLI]
+
+## Project Configuration
+sonar.projectKey=to.adian:sonar-scanner-cli-image
+sonar.exclusions=/.devcontainer/,/.gitlab/
+sonar.scm.provider=git
+
+## Project Identity
+sonar.projectName=SonarQube Scanner CLI Image
+sonar.projectVersion=latest
+
+## Authentication
+### sonar.login=[pass token via CLI]
\ No newline at end of file
-- 
GitLab