Skip to content

Commit 9bd361e

Browse files
authored
Merge pull request #2888 from Catrobat/release-0.9.34
Release-0.9.34
2 parents a0f2bf2 + 1f3bf1d commit 9bd361e

2,257 files changed

Lines changed: 115045 additions & 135066 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@ Thumbs.db
6262
.gradle/
6363
build/
6464

65+
# Cache for build scripts
66+
__pycache__
67+
6568
#api-keys
6669
catroid/google-services.json

Jenkinsfile

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#!groovy
2+
3+
pipeline {
4+
agent {
5+
dockerfile {
6+
filename 'Dockerfile.jenkins'
7+
// 'docker build' would normally copy the whole build-dir to the container, changing the
8+
// docker build directory avoids that overhead
9+
dir 'docker'
10+
// Pass the uid and the gid of the current user (jenkins-user) to the Dockerfile, so a
11+
// corresponding user can be added. This is needed to provide the jenkins user inside
12+
// the container for the ssh-agent to work.
13+
// Another way would be to simply map the passwd file, but would spoil additional information
14+
additionalBuildArgs '--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)'
15+
args "--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle/:/.gradle -v /var/local/container_shared/android-sdk:/usr/local/android-sdk -v /var/local/container_shared/android-home:/.android -v /var/local/container_shared/emulator_console_auth_token:/.emulator_console_auth_token -v /var/local/container_shared/analytics.settings:/analytics.settings"
16+
}
17+
}
18+
19+
environment {
20+
//////// Define environment variables to point to the correct locations inside the container ////////
21+
//////////// Most likely not edited by the developer
22+
ANDROID_SDK_ROOT = "/usr/local/android-sdk"
23+
// Deprecated: Still used by the used gradle version, once gradle respects ANDROID_SDK_ROOT, this can be removed
24+
ANDROID_HOME = "/usr/local/android-sdk"
25+
ANDROID_SDK_HOME = "/"
26+
// Needed for compatibiliby to current Jenkins-wide Envs. Can be removed, once all builds are migrated to Pipeline
27+
ANDROID_SDK_LOCATION = "/usr/local/android-sdk"
28+
ANDROID_NDK = ""
29+
// This is important, as we want the keep our gradle cache, but we can't share it between containers
30+
// the cache could only be shared if the gradle instances could comunicate with each other
31+
// imho keeping the cache per executor will have the least space impact
32+
GRADLE_USER_HOME = "/.gradle/${env.EXECUTOR_NUMBER}"
33+
// Otherwise user.home returns ? for java applications
34+
JAVA_TOOL_OPTIONS = "-Duser.home=/tmp/"
35+
36+
//// jenkins-android-helper related variables
37+
// set to any value to debug jenkins_android* scripts
38+
ANDROID_EMULATOR_HELPER_DEBUG = ""
39+
// get stdout of called subprocesses immediately
40+
PYTHONUNBUFFERED = "true"
41+
42+
//////// Build specific variables ////////
43+
//////////// May be edited by the developer on changing the build steps
44+
// modulename
45+
GRADLE_PROJECT_MODULE_NAME = "catroid"
46+
47+
// APK build output locations
48+
APK_LOCATION_DEBUG = "${env.GRADLE_PROJECT_MODULE_NAME}/build/outputs/apk/catroid/debug/catroid-catroid-debug.apk"
49+
APK_LOCATION_STANDALONE = "${env.GRADLE_PROJECT_MODULE_NAME}/build/outputs/apk/standalone/debug/catroid-standalone-debug.apk"
50+
51+
// share.catrob.at
52+
CATROBAT_SHARE_UPLOAD_BRANCH = "develop"
53+
CATROBAT_SHARE_APK_NAME = "org.catrobat.catroid_debug_${env.CATROBAT_SHARE_UPLOAD_BRANCH}_latest.apk"
54+
}
55+
56+
options {
57+
timeout(time: 2, unit: 'HOURS')
58+
timestamps()
59+
}
60+
61+
stages {
62+
stage('Setup Android SDK') {
63+
steps {
64+
// Install Android SDK
65+
lock("update-android-sdk-on-${env.NODE_NAME}") {
66+
sh "./buildScripts/build_step_install_android_sdk"
67+
}
68+
}
69+
}
70+
71+
stage('Static Analysis') {
72+
steps {
73+
sh "./buildScripts/build_step_run_static_analysis"
74+
}
75+
76+
post {
77+
always {
78+
pmd canComputeNew: false, canRunOnFailed: true, defaultEncoding: '', healthy: '', pattern: "${env.GRADLE_PROJECT_MODULE_NAME}/build/reports/pmd.xml", unHealthy: '', unstableTotalAll: '0'
79+
checkstyle canComputeNew: false, canRunOnFailed: true, defaultEncoding: '', healthy: '', pattern: "${env.GRADLE_PROJECT_MODULE_NAME}/build/reports/checkstyle.xml", unHealthy: '', unstableTotalAll: '0'
80+
androidLint canComputeNew: false, canRunOnFailed: true, defaultEncoding: '', healthy: '', pattern: "${env.GRADLE_PROJECT_MODULE_NAME}/build/reports/lint*.xml", unHealthy: '', unstableTotalAll: '0'
81+
}
82+
}
83+
}
84+
85+
stage('Unit and Device tests') {
86+
steps {
87+
// Run local unit tests
88+
sh "./buildScripts/build_step_run_unit_tests__all_tests"
89+
// ensure that the following test run does not overwrite the results
90+
sh "mv ${env.GRADLE_PROJECT_MODULE_NAME}/build ${env.GRADLE_PROJECT_MODULE_NAME}/build-unittest"
91+
92+
// Run device tests for package: org.catrobat.catroid.test
93+
sh "./buildScripts/build_step_run_tests_on_emulator__test_pkg"
94+
// ensure that the following test run does not overwrite the results
95+
sh "mv ${env.GRADLE_PROJECT_MODULE_NAME}/build ${env.GRADLE_PROJECT_MODULE_NAME}/build-test-test-pkg"
96+
97+
// Run device tests for class: org.catrobat.catroid.uiespresso.testsuites.PullRequestTriggerSuite
98+
sh "./buildScripts/build_step_run_tests_on_emulator__pr_test_suite"
99+
}
100+
101+
post {
102+
always {
103+
junit '**/*TEST*.xml'
104+
105+
// stop/kill emulator
106+
sh "./buildScripts/build_helper_stop_emulator"
107+
}
108+
}
109+
}
110+
111+
stage('Standalone-APK') {
112+
// It checks that the creation of standalone APKs (APK for a Pocketcode app) works, reducing the risk of breaking gradle changes.
113+
// The resulting APK is not verified itself.
114+
steps {
115+
sh "./buildScripts/build_step_create_standalone_apk"
116+
archiveArtifacts "${env.APK_LOCATION_STANDALONE}"
117+
}
118+
}
119+
120+
stage('Independent-APK') {
121+
// It checks that the job builds with the parameters to have unique APKs, reducing the risk of breaking gradle changes.
122+
// The resulting APK is not verified on itself.
123+
steps {
124+
sh "./buildScripts/build_step_create_independent_apk"
125+
stash name: "apk-independent", includes: "${env.APK_LOCATION_DEBUG}"
126+
archiveArtifacts "${env.APK_LOCATION_DEBUG}"
127+
}
128+
}
129+
130+
stage('Upload to share') {
131+
when {
132+
branch "${env.CATROBAT_SHARE_UPLOAD_BRANCH}"
133+
}
134+
135+
steps {
136+
unstash "apk-independent"
137+
script {
138+
uploadFileToShare "${env.APK_LOCATION_DEBUG}", "${env.CATROBAT_SHARE_APK_NAME}"
139+
}
140+
}
141+
}
142+
}
143+
144+
post {
145+
always {
146+
step([$class: 'LogParserPublisher', failBuildOnError: true, projectRulePath: 'buildScripts/log_parser_rules', unstableOnWarning: true, useProjectRule: true])
147+
148+
// Send notifications with standalone=false
149+
script {
150+
sendNotifications false
151+
}
152+
}
153+
}
154+
}

Jenkinsfile.BuildStandalone

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
#!groovy
2+
3+
pipeline {
4+
agent {
5+
dockerfile {
6+
filename 'Dockerfile.jenkins'
7+
// 'docker build' would normally copy the whole build-dir to the container, changing the
8+
// docker build directory avoids that overhead
9+
dir 'docker'
10+
// Pass the uid and the gid of the current user (jenkins-user) to the Dockerfile, so a
11+
// corresponding user can be added. This is needed to provide the jenkins user inside
12+
// the container for the ssh-agent to work.
13+
// Another way would be to simply map the passwd file, but would spoil additional information
14+
additionalBuildArgs '--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)'
15+
args "--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle/:/.gradle -v /var/local/container_shared/android-sdk:/usr/local/android-sdk -v /var/local/container_shared/android-home:/.android -v /var/local/container_shared/emulator_console_auth_token:/.emulator_console_auth_token -v /var/local/container_shared/analytics.settings:/analytics.settings"
16+
// Add specific 'Standalone'-label, so it can be made sure, that there is a dedicated host for standalone builds
17+
label 'Standalone'
18+
}
19+
}
20+
21+
environment {
22+
//////// Define environment variables to point to the correct locations inside the container ////////
23+
//////////// Most likely not edited by the developer
24+
ANDROID_SDK_ROOT = "/usr/local/android-sdk"
25+
// Deprecated: Still used by the used gradle version, once gradle respects ANDROID_SDK_ROOT, this can be removed
26+
ANDROID_HOME = "/usr/local/android-sdk"
27+
ANDROID_SDK_HOME = "/"
28+
// Needed for compatibiliby to current Jenkins-wide Envs. Can be removed, once all builds are migrated to Pipeline
29+
ANDROID_SDK_LOCATION = "/usr/local/android-sdk"
30+
ANDROID_NDK = ""
31+
// This is important, as we want the keep our gradle cache, but we can't share it between containers
32+
// the cache could only be shared if the gradle instances could comunicate with each other
33+
// imho keeping the cache per executor will have the least space impact
34+
GRADLE_USER_HOME = "/.gradle/${env.EXECUTOR_NUMBER}"
35+
// Otherwise user.home returns ? for java applications
36+
JAVA_TOOL_OPTIONS = "-Duser.home=/tmp/"
37+
38+
//// jenkins-android-helper related variables
39+
// set to any value to debug jenkins_android* scripts
40+
ANDROID_EMULATOR_HELPER_DEBUG = ""
41+
// get stdout of called subprocesses immediately
42+
PYTHONUNBUFFERED = "true"
43+
44+
//////// Build specific variables ////////
45+
//////////// May be edited by the developer on changing the build steps
46+
// modulename
47+
GRADLE_PROJECT_MODULE_NAME = "catroid"
48+
49+
// APK build output locations
50+
APK_LOCATION_STANDALONE = "${env.GRADLE_PROJECT_MODULE_NAME}/build/outputs/apk/standalone/debug/catroid-standalone-debug.apk"
51+
}
52+
53+
options {
54+
timeout(time: 600, unit: 'SECONDS')
55+
timestamps()
56+
}
57+
58+
stages {
59+
stage('Prepare build') {
60+
steps {
61+
script {
62+
currentBuild.displayName = "${env.DOWNLOAD}"
63+
}
64+
}
65+
}
66+
67+
stage('Setup Android SDK') {
68+
steps {
69+
// Install Android SDK
70+
lock("update-android-sdk-on-${env.NODE_NAME}") {
71+
sh "./buildScripts/build_step_install_android_sdk"
72+
}
73+
}
74+
}
75+
76+
stage('Check-for-invalid-program-upload') {
77+
steps {
78+
script {
79+
def ret = sh returnStatus: true, script: '''#!/bin/sh
80+
SLEEP_TIME=5
81+
RETRIES=5
82+
83+
HTTP_STATUS_OK=200
84+
HTTP_STATUS_INVALID_FILE_UPLOAD=528
85+
86+
## check if program is downloadable from web
87+
## If we can't load it, we retry it ${RETRIES} times
88+
## On a 528 status (invalid upload), we return 200 which
89+
## should get interpreted as UNSTABLE build
90+
while true; do
91+
HTTP_STATUS=`curl --write-out %{http_code} --silent --output /dev/null "${DOWNLOAD}"`
92+
93+
if [ ${HTTP_STATUS} -eq ${HTTP_STATUS_OK} ]; then
94+
break
95+
fi
96+
97+
98+
RETRIES=$((RETRIES-1))
99+
if [ ${RETRIES} -eq 0 ]; then
100+
if [ ${HTTP_STATUS} -eq ${HTTP_STATUS_INVALID_FILE_UPLOAD} ]; then
101+
echo "Uploaded file seems to be invalid, request to '${DOWNLOAD}' returned HTTP Status ${HTTP_STATUS}"
102+
exit 200
103+
else
104+
echo "Could not download '${DOWNLOAD}', giving up!"
105+
exit 1
106+
fi
107+
fi
108+
109+
echo "Could not retrieve '${DOWNLOAD}' (HTTP Status ${HTTP_STATUS}), sleep for ${SLEEP_TIME}s and retry a maximum of ${RETRIES} times"
110+
sleep ${SLEEP_TIME}
111+
done
112+
'''
113+
114+
// if no error, we are done
115+
if (ret == 0) {
116+
return
117+
}
118+
119+
// Handle special error from the script, if the program download was not
120+
// possible because of the HTTP error 528, we set the build to UNSTABLE
121+
try {
122+
error('')
123+
} catch (err) {
124+
if (ret == 200) {
125+
currentBuild.result = 'UNSTABLE'
126+
} else {
127+
currentBuild.result = 'FAILURE'
128+
}
129+
}
130+
}
131+
}
132+
}
133+
134+
stage('Build APK') {
135+
// needed, as long as we mark the build unstable when we receive the 528 error from WEB
136+
when {
137+
expression {
138+
currentBuild.result == null
139+
}
140+
}
141+
142+
steps {
143+
sh "./buildScripts/build_step_create_standalone_apk '${DOWNLOAD}' '${SUFFIX}'"
144+
archiveArtifacts "${env.APK_LOCATION_STANDALONE}"
145+
}
146+
}
147+
148+
stage('Upload to Web') {
149+
// needed, as long as we mark the build unstable when we receive the 528 error from WEB
150+
when {
151+
expression {
152+
currentBuild.result == null
153+
}
154+
}
155+
156+
steps {
157+
script {
158+
uploadFileToWeb "${env.APK_LOCATION_STANDALONE}", "${env.UPLOAD}"
159+
}
160+
}
161+
}
162+
}
163+
164+
post {
165+
always {
166+
step([$class: 'LogParserPublisher', failBuildOnError: true, projectRulePath: 'buildScripts/log_parser_rules', unstableOnWarning: true, useProjectRule: true])
167+
168+
// Send notifications with standalone=true
169+
script {
170+
sendNotifications true
171+
}
172+
}
173+
}
174+
}

0 commit comments

Comments
 (0)