@@ -28,27 +28,27 @@ def global_sum_log = ""
2828def added_commits = " "
2929def builder_node = " "
3030def builder_wspace = " "
31- def slot_name = " builder-slot -"
31+ def slot_name = " ci -"
3232// reasonable value: keep few recent, dont take risk to fill disk
3333int num_build_dirs_to_keep = 4
3434
3535// Define global environment common for all docker sessions
3636def script_env = """
3737 export WORKSPACE=\$ PWD
3838 export HOME=\$ JENKINS_HOME
39- export CURRENT_PROJECT=${ current_project}
4039 export BUILD_CACHE_DIR=${ env.PUBLISH_DIR} /bb-cache
4140 export GIT_PROXY_COMMAND=oe-git-proxy
4241 export CI_BUILD_ID=${ ci_build_id}
4342 export GIT_COMMITTER_NAME="IOT Refkit CI"
4443 export GIT_COMMITTER_EMAIL='refkit-ci@yoctoproject.org'
4544 export TARGET_MACHINE=${ target_machine}
45+ export CI_LOG=bitbake-${ target_machine} -${ ci_build_id} .log
4646"""
4747
4848try {
4949 timestamps {
5050 node(' rk-docker' ) {
51- ws(" workspace/${ slot_name}${ env.EXECUTOR_NUMBER } " ) {
51+ ws(" workspace/${ slot_name}${ ci_build_id } " ) {
5252 // remember node and workspace needed by workspace cleaner
5353 builder_node = " ${ env.NODE_NAME} "
5454 builder_wspace = " ${ env.WORKSPACE} "
@@ -102,11 +102,6 @@ try {
102102 added_commits = readFile(" added_commits" )
103103 }
104104 } // ws
105- // rotate workspace out of way, rename using CI_BUILD_ID.
106- // Older trees are deleted later in test_runs[], without keeping build waiting.
107- ws(" workspace" ) {
108- sh " mv ${ builder_wspace} ${ builder_wspace} .ci-prev.${ ci_build_id} "
109- }
110105 } // node
111106 } // timestamps
112107
@@ -146,9 +141,12 @@ try {
146141 } finally {
147142 // read tests summary prepared by tester-exec.sh
148143 // Here one tester adds it's summary piece to the global buffer.
149- global_sum_log + = readFile " results-summary-${ test_device} .${ img} .log"
150- archiveArtifacts allowEmptyArchive : true ,
151- artifacts : ' *.log, *.xml'
144+ // Grab lock as we deal with global data from multiple workers
145+ lock(resource : " global_data" ) {
146+ global_sum_log + = readFile " results-summary-${ test_device} .${ img} .log"
147+ archiveArtifacts allowEmptyArchive : true ,
148+ artifacts : ' *.log, *.xml'
149+ }
152150 }
153151 // without locking we may lose tester result set(s)
154152 // if testers run xunit step in nearly same time
@@ -220,12 +218,10 @@ def run_proxy_args() {
220218
221219def build_user_args () {
222220 dir(pwd([tmp :true ])+ " /.build_user_args" ) {
223- // get jenkins user uid/gid
224- sh " id -u > jenkins_uid"
221+ // get jenkins user uid/gid
222+ sh " id -u > jenkins_uid && id -g > jenkins_gid "
225223 jenkins_uid = readFile(" jenkins_uid" ). trim()
226- sh " id -g > jenkins_gid"
227224 jenkins_gid = readFile(" jenkins_gid" ). trim()
228- deleteDir()
229225 }
230226 return " --build-arg uid=${ jenkins_uid} --build-arg gid=${ jenkins_gid} "
231227}
@@ -300,12 +296,17 @@ def step_xunit() {
300296}
301297
302298// Delete older builder trees.
303- // While majority/regular workspaces are named builder-slot-0, (for EXECUTOR=0) ,
304- // Jenkins may create additional trees as builder-slot-0_X.
305- // Wildcard covers all such workspaces, dont want some pattern filling disk independently .
299+ // While majority/regular workspaces are named ci-CI_BUILD_ID ,
300+ // Jenkins may create additional trees as ci-build-CI_BUILD_ID_<NUM>
301+ // Regex with underscore should cover all such workspaces .
306302def trim_build_dirs (slotname , num_to_keep ) {
307303 sh """
308- dirs=`find ${ env.WORKSPACE} -mindepth 1 -maxdepth 1 -type d -name "${ slotname} *.ci-prev.*" |sort -n |head -n -${ num_to_keep} |tr '\n ' ' '`
304+ # tmpdirs in separate pass
305+ dirs=`find . -mindepth 1 -maxdepth 1 -type d -regex ".*/${ slotname} [0-9_-]*-build-[0-9_]*.*tmp\$ " |sort -n |head -n -${ num_to_keep} |tr '\n ' ' '`
306+ if [ -n "\$ {dirs}" ]; then
307+ ionice -c 3 rm -fr \$ dirs
308+ fi
309+ dirs=`find . -mindepth 1 -maxdepth 1 -type d -regex ".*/${ slotname} [0-9_-]*-build-[0-9_]*\$ " |sort -n |head -n -${ num_to_keep} |tr '\n ' ' '`
309310if [ -n "\$ {dirs}" ]; then
310311 ionice -c 3 rm -fr \$ dirs
311312fi
0 commit comments