Для того что бы поднять Jenkins в докер, какие Volume пробрасывать сами решайте, это полностью скопированная моя конфигурация для примера
docker run -it -d -v jenkins_home:/var/jenkins_home -v /usr/lib/android-sdk:/usr/lib/android-sdk -v /opt/tomcat-latest/webapps:/opt/tomcat-latest/webapps -p 8070:8080 -p 50000:50000 --env JENKINS_OPTS="--prefix=/jenkins" --restart always leganas/ls_repository:jenkins
Git хук, который выполняет curl к jenkins , если push событие было в ветку мастер. Этот гит хук можно прописывать не только в Gita, можно сразу в папку gita в хуки прописать и будет так же работать в любом git репозитарии.
#!/bin/bash while read oldrev newrev refname do branch=$(git rev-parse --symbolic --abbrev-ref $refname) if [ "master" = "$branch" ]; then curl --user USER:API_Token https://legan.by/jenkins/job/MenuAndMarket/build?token=TOKEN_JENKINS fi done
ПС. Если ветка не важна, можно убрать всё кроме 1 строки и самой строчки curl
Настройки build.gradle уровня app для автоматической генерации номера версии на приложения на основании даты и времени
... def getVersionNameTimestamp() { return new Date().format('yy.MM.ddHHmm') } def getVersionCodeTimestamp() { def date = new Date() def formattedDate = date.format('yyMMddHHmm') def code = formattedDate.toInteger() println sprintf("VersionCode: %d", code) return code } ... android { ... defaultConfig { ... versionCode getVersionCodeTimestamp() versionName "${getVersionNameTimestamp()}"
Настройки build.gradle уровня app для автоматической подписи apk
// Load keystore def keystorePropertiesFile = rootProject.file("keystore.properties") def keystoreProperties = new Properties() keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) ... android { signingConfigs { config { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] } } ... buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.config }
Пример JSON Shema приходящий от Gitea , есть прекрасный ресурс позволяющий превратить это в Java классы http://www.jsonschema2pojo.org/
{ "secret": "3gEsCfjlV2ugRwgpU#w1*WaW*wa4NXgGmpCfkbG3", "ref": "refs/heads/develop", "before": "28e1879d029cb852e4844d9c718537df08844e03", "after": "bffeb74224043ba2feb48d137756c8a9331c449a", "compare_url": "http://localhost:3000/gitea/webhooks/compare/28e1879d029cb852e4844d9c718537df08844e03...bffeb74224043ba2feb48d137756c8a9331c449a", "commits": [ { "id": "bffeb74224043ba2feb48d137756c8a9331c449a", "message": "Webhooks Yay!", "url": "http://localhost:3000/gitea/webhooks/commit/bffeb74224043ba2feb48d137756c8a9331c449a", "author": { "name": "Gitea", "email": "someone@gitea.io", "username": "gitea" }, "committer": { "name": "Gitea", "email": "someone@gitea.io", "username": "gitea" }, "timestamp": "2017-03-13T13:52:11-04:00" } ], "repository": { "id": 140, "owner": { "id": 1, "login": "gitea", "full_name": "Gitea", "email": "someone@gitea.io", "avatar_url": "https://localhost:3000/avatars/1", "username": "gitea" }, "name": "webhooks", "full_name": "gitea/webhooks", "description": "", "private": false, "fork": false, "html_url": "http://localhost:3000/gitea/webhooks", "ssh_url": "ssh://gitea@localhost:2222/gitea/webhooks.git", "clone_url": "http://localhost:3000/gitea/webhooks.git", "website": "", "stars_count": 0, "forks_count": 1, "watchers_count": 1, "open_issues_count": 7, "default_branch": "master", "created_at": "2017-02-26T04:29:06-05:00", "updated_at": "2017-03-13T13:51:58-04:00" }, "pusher": { "id": 1, "login": "gitea", "full_name": "Gitea", "email": "someone@gitea.io", "avatar_url": "https://localhost:3000/avatars/1", "username": "gitea" }, "sender": { "id": 1, "login": "gitea", "full_name": "Gitea", "email": "someone@gitea.io", "avatar_url": "https://localhost:3000/avatars/1", "username": "gitea" } }