Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Docker and Setup CD #135

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04
MAINTAINER Stefano Pacifici <[email protected]>
ENV DEBIAN_FRONTEND noninteractive

Expand Down Expand Up @@ -61,7 +61,7 @@ ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
ENV ANDROID_HOME /home/jenkins/android_home
ENV GRADLE_USER_HOME /home/jenkins/gradle_home
ENV NVM_DIR /home/jenkins/nvm
ENV NODE_VERSION 8.9.3
ENV NODE_VERSION 9.11.2

USER jenkins

Expand All @@ -74,33 +74,38 @@ RUN mkdir -p $ANDROID_HOME; \
rm -r sdktools.zip; \
(while (true); do echo y; sleep 2; done) | \
tools/bin/sdkmanager \
"build-tools;26.0.2" \
"platforms;android-23" \
"platforms;android-27" \
"build-tools;28.0.3" \
"platforms;android-28" \
"platform-tools" \
"tools" \
"platforms;android-25" \
"extras;google;m2repository" \
"extras;android;m2repository" \
"extras;google;google_play_services";

ENV LD_LIBRARY_PATH "/home/jenkins/android_home/emulator/lib64/qt/lib"

# Install Node.JS
SHELL ["/bin/bash", "-l", "-c"]
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash && \
. $NVM_DIR/nvm.sh

ENV PATH "$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH"

#Installation of 'yarn'; 'appium' & 'wd' for Integration Tests
RUN npm install --global \
yarn \
appium \
wd
#Installation of Updated 'npm'
RUN npm install --global npm

#Install Ruby and Fastlane
RUN for key in 409B6B1796C275462A1703113804BB82D39DC0E3 \
7D2BAF1CF37B13E2069D6956105BD0E739499BDB; do \
for server in "hkp://keys.gnupg.net" \
"hkp://p80.pool.sks-keyservers.net:80" \
"pgp.mit.edu" \
"hkp://keyserver.ubuntu.com:80"; do \
gpg2 --keyserver "${server}" --recv-keys "${key}" || echo "Trying new server..."; \
done; \
done
RUN curl -sSL https://get.rvm.io | bash -s stable --ruby=2.4.3 --autolibs=read-fail && \
source /home/jenkins/.rvm/scripts/rvm \
rvm reload && \
gem install fastlane --version 2.126.0

RUN gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 && \
curl -sSL https://get.rvm.io | bash -s stable --ruby=2.4.1 --autolibs=read-fail
RUN gem install fastlane
#Install AWS CLI
RUN pip install awscli --upgrade --user
107 changes: 57 additions & 50 deletions Jenkinsfile.upload
Original file line number Diff line number Diff line change
@@ -1,66 +1,73 @@
#!/bin/env groovy

@Library(['[email protected]']) _
properties([
parameters([
choice(choices: ['cliqz', 'lumen'], defaultValue: 'lumen', description: 'Which Product ?', name: 'product')
])
])
node('master'){
def imageName = 'android-browser'
def branchName = "${BRANCH_NAME}"

stage('Checkout'){
checkout scm
}

stage('Build docker image') {
docker.build(imageName, '--build-arg UID=`id -u` --build-arg GID=`id -g` .')
}

docker.image(imageName).inside() {
stage('Extension') {
sh '''
set -x
set -e
yarn
npm run bundle
'''
}

withEnv(["GRADLE_USER_HOME=${pwd()}/gradle_home","BN=${branchName}"]) {
withCredentials([
file(credentialsId: '263e59fb-e9de-4e51-962c-0237c6ee167b', variable: 'CERT_PATH'),
string(credentialsId: '60354bba-8ed0-4df9-8f8e-5be7454c1680', variable: 'CERT_PASS'),
file(credentialsId: '2939d2e1-dd9a-4097-adc2-430e3d67157a', variable: 'PLAY_STORE_CERT')]) {
sh 'echo $BN'
if ("${BN}".contains("-re")) {
stage('Compile') {
sh './gradlew clean assembleStandardFatRelease'
}
}else {
try {
stage('Extension') {
sh '''#!/bin/bash -l
set -x
set -e
npm ci
npm run bundle
'''
}
withEnv(["GRADLE_USER_HOME=${pwd()}/gradle_home"]) {
withCredentials([
file(credentialsId: '263e59fb-e9de-4e51-962c-0237c6ee167b', variable: 'CERT_PATH'),
string(credentialsId: '60354bba-8ed0-4df9-8f8e-5be7454c1680', variable: 'CERT_PASS'),
file(credentialsId: '2939d2e1-dd9a-4097-adc2-430e3d67157a', variable: 'PLAY_STORE_CERT'),
file(credentialsId: '3796eb16-42cd-4551-a5a5-c4fe3a18719a', variable: 'CLIQZ_CONFIG_JSON'),
file(credentialsId: '6006a534-9f2e-4ba8-93f9-f0f27c0713df', variable: 'GOOGLE_SERVICES')]) {
stage('Compile and Upload') {
sh '''#!/bin/bash -l
set -x
set -e
fastlane android alpha
'''
sh '''#!/bin/bash -l
set -x
set -e
cp $CLIQZ_CONFIG_JSON app/cliqz-config.json
cp $GOOGLE_SERVICES app/google-services.json
'''
if(params.product == "cliqz") {
sh '''#!/bin/bash -l
set -x
set -e
export APP_PACKAGE="com.cliqz.browser"
fastlane android internal_cliqz
'''
}
if(params.product == "lumen") {
sh '''#!/bin/bash -l
set -x
set -e
export APP_PACKAGE="com.cliqz.lumen"
fastlane android internal_lumen
'''
}
}
}
}
}
}

}
if ("${branchName}".contains("-re")) {
def id = "Cliqz_Browser_android"+"${branchName}".substring("${branchName}".indexOf("v"), "${branchName}".indexOf("-"))
stage('Upload') {
withCredentials([
[
$class : 'UsernamePasswordMultiBinding',
credentialsId : 'f1732e5f-3e84-47ad-9286-a5fa6657ec43',
passwordVariable: 'AWS_SECRET_ACCESS_KEY',
usernameVariable: 'AWS_ACCESS_KEY_ID',
]
]) {
def s3Path = 's3://repository.cliqz.com/dist/android/release/apk'
def apkPath = "app/build/outputs/apk/standardFat/release/app-standard-fat-release.apk"

sh "aws s3 cp --acl public-read --acl bucket-owner-full-control ${apkPath} ${s3Path}/${id}.apk"
sh "aws s3 cp --acl public-read --acl bucket-owner-full-control ${s3Path}/${id}.apk ${s3Path}/latest.apk"
} finally {
stage('Upload Artifacts and Clean Up') {
archiveArtifacts allowEmptyArchive: true, artifacts: 'app/build/**/*.apk'
sh'''#!/bin/bash -l
set -x
set -e
rm -f app/cliqz-config.json
rm -f app/google-services.json
rm -rf app/build
rm -rf jsengine/*
rm -rf gradle_home/
'''
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
}

defaultConfig {
versionCode 106
versionCode 1
versionName "1.8.4"
multiDexEnabled true

Expand Down
10 changes: 6 additions & 4 deletions buildSrc/src/main/java/com/cliqz/gradle/CliqzPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ class CliqzPlugin: Plugin<Project> {
}
}

val defaultVersionCode = android.defaultConfig.versionCode
project.afterEvaluate {
android.applicationVariants.forEach { variant ->
setVersionCode(defaultVersionCode, variant)
setVersionCode(variant)
createCliqzConfigTasks(project, variant)
}
}
Expand Down Expand Up @@ -54,14 +53,17 @@ class CliqzPlugin: Plugin<Project> {
}
}

private fun setVersionCode(defaultVersionCode: Int, variant: ApplicationVariant) {
private fun setVersionCode(variant: ApplicationVariant) {
val buildNumber = System.getenv("BUILD_NUMBER")?.toIntOrNull()
if (buildNumber == null) return;
val versionCode = 110 + buildNumber
val apiVersion = variant.productFlavors[0].versionCode
variant.outputs.forEach { output ->
val abi = output.filters.find { it.filterType == OutputFile.ABI }
abi?.let {
val abiVersion = ABI_CODES[it.identifier]
(output as ApkVariantOutput).versionCodeOverride =
defaultVersionCode * 100 + apiVersion * 10 + abiVersion!!
versionCode * 100 + apiVersion * 10 + abiVersion!!
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
json_key_file(ENV["PLAY_STORE_CERT"]) # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("com.cliqz.browser") # e.g. com.krausefx.app
package_name(ENV["APP_PACKAGE"]) # e.g. com.krausefx.app
19 changes: 15 additions & 4 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@
#

# Uncomment the line if you want fastlane to automatically update itself
update_fastlane
# update_fastlane

default_platform(:android)

platform :android do
desc "Submit a new alpha Build to the Google Play Store"
lane :alpha do
gradle(task: "clean assembleStandardArmRelease assembleStandardX6Release")
lane :internal_lumen do
gradle(task: "clean assembleLumenRelease")
upload_to_play_store(
apk_paths:ENV["GRADLE_ALL_APK_OUTPUT_PATHS"],
track:"alpha",
track:"internal",
skip_upload_metadata: true,
skip_upload_images: true,
skip_upload_screenshots: true,
)
end

lane :internal_cliqz do
gradle(task: "clean assembleCliqzRelease")
upload_to_play_store(
apk_paths:ENV["GRADLE_ALL_APK_OUTPUT_PATHS"],
track:"internal",
skip_upload_metadata: true,
skip_upload_images: true,
skip_upload_screenshots: true,
Expand Down