Skip to content
Open
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
58 changes: 46 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,60 @@
FROM antonkazakov/otus
FROM jenkins/jenkins:2.361.1-jdk11

RUN mkdir /opt/project
COPY . /opt/project
WORKDIR /opt/project
ENV DEBIAN_FRONTEND noninteractive
ENV LANG 'en_US.UTF-8'

USER root

RUN dpkg --add-architecture i386 && apt-get update -yqq && apt-get install -y \
curl \
expect \
git \
make \
git-core \
libc6:i386 \
libgcc1:i386 \
libncurses5:i386 \
libstdc++6:i386 \
zlib1g:i386 \
openjdk-11-jdk \
wget \
unzip \
vim \
openssh-client \
locales \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV VERSION_SDK_TOOLS "8092744_latest"
ENV ANDROID_SDK_ROOT "/sdk"
ENV PATH "${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator:${GRADLE_PROFILER}/bin"

RUN mkdir ${ANDROID_SDK_ROOT}
RUN chown -R jenkins ${ANDROID_SDK_ROOT}

ENV VERSION_SDK_TOOLS "8092744"
ENV GRADLE_PROFILER "/gradle-profiler/gradle-profiler-0.18.0"
ENV PATH "${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator:${GRADLE_PROFILER}/bin"

RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
wget https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \
unzip *tools*linux*.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/tools && \
wget https://dl.google.com/android/repository/commandlinetools-linux-${VERSION_SDK_TOOLS}_latest.zip && \
unzip *tools*linux*.zip -d ${ANDROID_SDK_ROOT} && \
rm *tools*linux*.zip

RUN ${ANDROID_SDK_ROOT}/cmdline-tools/bin/sdkmanager --update --sdk_root=${ANDROID_SDK_ROOT}

COPY gradle-profiler-0.18.0.zip gradle-profiler/

RUN unzip gradle-profiler/gradle-profiler-0.18.0.zip -d gradle-profiler && rm -v gradle-profiler/gradle-profiler-0.18.0.zip

RUN yes | sdkmanager --licenses && \
sdkmanager "platforms;android-32" "build-tools;30.0.2" && \
cd /opt/project
RUN yes | ${ANDROID_SDK_ROOT}/cmdline-tools/bin/sdkmanager --licenses --sdk_root=${ANDROID_SDK_ROOT}

RUN apt-get update && apt-get install -y lsb-release
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \
https://download.docker.com/linux/debian/gpg
RUN echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \
https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
RUN apt-get update && apt-get install -y docker-ce-cli

USER jenkins
72 changes: 72 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!groovy
pipeline {
agent {
docker {
image 'exfaust/seniorproject:1.0.8'
}
}
parameters {
string(name: 'branch', defaultValue: 'development', description: 'Branch to build')
}
stages {
stage("branch") {
steps {
checkout([
$class : 'GitSCM',
branches : [[name: "*/${params.branch}"]],
extensions : [],
userRemoteConfigs: [[url: 'https://github.com/ExFaust/SeniorProject.git']]
])
}
}
stage("init") {
steps {
sh "chmod +x gradlew"
sh "./gradlew --no-daemon"
}
}
stage('detekt') {
steps {
sh "./gradlew lintDebug"
}
}
stage("test") {
steps {
script {
if (params.branch.contains('release/')) {
sh "./gradlew testReleaseUnitTest"
}
else {
sh "./gradlew testDebugUnitTest"
}
}
}
}
stage("build") {
steps {
script {
if (params.branch.contains('release/')) {
sh "./gradlew assembleRelease"
}
else {
sh "./gradlew assembleDebug"
}
}
}
}
stage("publish") {
steps {
sh "./gradlew publishToMavenLocal"
}
}
}
post {
failure {
script {
if (getContext(hudson.FilePath)) {
archiveArtifacts(artifacts: '**/build/reports/**', allowEmptyArchive: true)
}
}
}
}
}
38 changes: 38 additions & 0 deletions Jenkinsfile-with-profiler
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!groovy
pipeline {
agent {
docker {
image 'exfaust/seniorproject:1.0.8'
}
}
triggers{ cron('0 22 * * *') }
parameters {
string(name: 'branch', defaultValue: 'development', description: 'Branch to build')
}
stages {
stage("branch") {
steps {
checkout([
$class : 'GitSCM',
branches : [[name: "*/${params.branch}"]],
extensions : [],
userRemoteConfigs: [[url: 'https://github.com/ExFaust/SeniorProject.git']]
])
}
}
stage("gradle-profiler") {
steps {
sh "gradle-profiler --benchmark --project-dir ${WORKSPACE} :app:assembleDebug"
}
}
}
post {
failure {
script {
if (getContext(hudson.FilePath)) {
archiveArtifacts(artifacts: '**/build/reports/**', allowEmptyArchive: true)
}
}
}
}
}
15 changes: 15 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@ plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'maven-publish'
}

def properties = new Properties()
file("otus_keystore_credentials_file.properties").withInputStream {
stream -> properties.load(stream)
}

android {
compileSdk 32

signingConfigs {
release {
keyAlias properties.getProperty("KEY_ALIAS")
keyPassword properties.getProperty("KEY_PASSWORD")
storeFile file('../otus_keystore_file.jks')
storePassword properties.getProperty("KEYSTORE_PASSWORD")
}
}

defaultConfig {
applicationId "com.exfaust.seniorproject"
minSdk 26
Expand Down
3 changes: 3 additions & 0 deletions app/otus_keystore_credentials_file.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
KEYSTORE_PASSWORD=qwerty
KEY_ALIAS=key0
KEY_PASSWORD=qwerty
Binary file added app/release/app-release.aab
Binary file not shown.

This file was deleted.

16 changes: 0 additions & 16 deletions app/src/test/java/com/exfaust/seniorproject/ExampleUnitTest.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

15 changes: 13 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand All @@ -20,4 +20,15 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
org.gradle.daemon=false
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.caching=true
kotlin.incremental=true
android.lifecycleProcessor.incremental=true
android.defaults.buildfeatures.aidl=false
android.defaults.buildfeatures.renderscripts=false
android.defaults.buildfeatures.viewbinding=false
android.defaults.buildfeatures.compose=false
android.defaults.buildfeatures.shaders=false
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading