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
65 changes: 65 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM jenkins/jenkins:2.361.1-jdk11

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 ANDROID_SDK_ROOT "/sdk"

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.19.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-${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.19.0.zip gradle-profiler/

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

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
66 changes: 66 additions & 0 deletions src/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!groovy
pipeline {
agent {
docker {
image 'infernno/androidimage:1.0.0'
}
}
parameters {
string(name: 'branch', defaultValue: 'development', description: 'Source branh')
}
stages {
stage("Checkout") {
steps {
checkout([
$class : 'GitSCM',
branches : [[name: "*/${params.branch}"]],
extensions : [],
userRemoteConfigs: [[url: 'https://github.com/Infernno/gamehub.git']]
])
}
}
stage('Lint') {
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 src/JenkinsfileGradleProfiler
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!groovy
pipeline {
agent {
docker {
image 'infernno/androidimage:1.0.0'
}
}
triggers{ cron('0 22 * * *') }
parameters {
string(name: 'branch', defaultValue: 'development', description: 'Source branch')
}
stages {
stage("Checkout") {
steps {
checkout([
$class : 'GitSCM',
branches : [[name: "*/${params.branch}"]],
extensions : [],
userRemoteConfigs: [[url: 'https://github.com/Infernno/gamehub.git']]
])
}
}
stage("Gradle Profiler") {
steps {
sh "gradle-profiler --benchmark --project-dir ${WORKSPACE} :app:assembleDebug"
}
}
}
post {
failure {
script {
if (getContext(hudson.FilePath)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем нужно это условие?

archiveArtifacts(artifacts: '**/build/reports/**', allowEmptyArchive: true)
}
}
}
}
}
20 changes: 19 additions & 1 deletion src/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io.gamehub.buildlogic.BuildConfig
import java.util.*

plugins {
Expand All @@ -12,6 +13,14 @@ if (localProperties.exists() && localProperties.isFile) {
}
}

val keystoreProps = Properties()
val keystoreProperties = File(rootProject.rootDir, "keystore.properties")
if (keystoreProperties.exists() && keystoreProperties.isFile) {
localProperties.inputStream().use { input ->
keystoreProps.load(input)
}
}

android {
namespace = "io.gamehub"

Expand All @@ -20,9 +29,18 @@ android {
versionCode = 1
versionName = "1.0"

val apiKey = checkNotNull(localProps.getProperty("rawg.apiKey"))
val apiKey = checkNotNull(localProps.getProperty("rawg.apiKey") ?: System.getenv()["RAWG_API_KEY"])
buildConfigField("String", "RAWG_API_KEY", "\"$apiKey\"")
}

signingConfigs {
create("release") {
keyAlias = keystoreProps.getProperty("alias")
keyPassword = keystoreProps.getProperty("password")
storeFile = File(rootProject.rootDir, "keystore.jks")
storePassword = keystoreProps.getProperty("password")
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("debug")
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
@Suppress("DSL_SCOPE_VIOLATION") // Intellij Bug
plugins {
Expand All @@ -11,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.dagger.hilt) apply false
alias(libs.plugins.detekt) apply false
}

tasks.register<Delete>("clean") {
Expand Down
2 changes: 2 additions & 0 deletions src/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ androidxMetrics = "1.0.0-alpha03"
googleMaterial = "1.6.1"
arrowKt = "1.1.3"
room = "2.4.3"
detekt = "1.21.0"

# Compose
androidxCompose = "1.3.0-rc01"
Expand Down Expand Up @@ -185,3 +186,4 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger2" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
Binary file added src/keystore.jks
Binary file not shown.
2 changes: 2 additions & 0 deletions src/keystore.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alias=gamehub
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему ты релизный кейстор и креды к нему положил в репозиторий? Это совершенно небезопасно, нужно было положить в креды и организовать биндинг https://plugins.jenkins.io/credentials-binding/

password=test123