(SHIFT) Add Jenkinsfile
Change-Id: I30fe6ef0284ed822d66cd81012e0eefdd94d1a48
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..c44268b
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,83 @@
+class Constants {
+ static final String RELEASE_BRANCH = 'release'
+
+ static final String QA_BUILD = 'Debug'
+ static final String RELEASE_BUILD = 'Release'
+
+ static final String INTERNAL_TRACK = 'internal'
+ static final String RELEASE_TRACK = 'release'
+}
+
+def getBuildType() {
+ switch (env.BRANCH_NAME) {
+ case Constants.RELEASE_BRANCH:
+ return Constants.RELEASE_BUILD
+ default:
+ return Constants.QA_BUILD
+ }
+}
+
+def getTrackType() {
+ switch (env.BRANCH_NAME) {
+ case Constants.RELEASE_BRANCH:
+ return Constants.RELEASE_TRACK
+ default:
+ return Constants.INTERNAL_TRACK
+ }
+}
+
+def isDeployCandidate() {
+ return ("${env.BRANCH_NAME}" =~ /(${RELEASE_BRANCH}|main|next)/)
+}
+
+pipeline {
+ agent any
+
+ environment {
+ appName = 'Aperture'
+
+ SIGN_STORE = credentials('sign_store_shift_releasekey')
+ SIGN_STORE_PASS = credentials('sign_store_pass_shift_releasekey')
+ SIGN_KEY_ALIAS = credentials('sign_key_alias_shift_releasekey')
+ SIGN_KEY_PASS = credentials('sign_key_pass_shift_releasekey')
+ }
+
+ stages {
+ stage('Build') {
+ steps {
+ echo "Building '$appName'"
+ script {
+ VARIANT = getBuildType()
+ sh('./gradlew \
+ -Psign_store="$SIGN_STORE" \
+ -Psign_store_pass="$SIGN_STORE_PASS" \
+ -Psign_key_alias="$SIGN_KEY_ALIAS" \
+ -Psign_key_pass="$SIGN_KEY_PASS" '
+ + "assemble$VARIANT")
+
+ archiveArtifacts \
+ artifacts: 'app/build/outputs/apk/**/*.apk, app/build/outputs/apk/**/*.json', \
+ fingerprint: true, \
+ followSymlinks: false, \
+ onlyIfSuccessful: true
+ }
+ cleanWs()
+ }
+ }
+ }
+
+ post {
+ success {
+ mattermostSend \
+ color: 'good', \
+ message: "SUCCESS -> ${env.JOB_NAME} (#${env.BUILD_NUMBER})\n(<${env.BUILD_URL}|Open>)", \
+ text: ':android: :bongo_blob: :blob_dance: :bongo_blob: :android:'
+ }
+ failure {
+ mattermostSend \
+ color: 'danger', \
+ message: "FAILURE -> ${env.JOB_NAME} (#${env.BUILD_NUMBER})\n(<${env.BUILD_URL}|Open>)", \
+ text: ':facepalm: :sarcastic: :dull_: :sarcastic: :facepalm:'
+ }
+ }
+}