rebuilt script structure

rebuilt script structure
This commit is contained in:
psycho 2020-11-09 14:47:41 +01:00
parent 5658e69b97
commit b2f83de4f6

53
Jenkinsfile vendored
View File

@ -23,6 +23,7 @@ def verbose = false
def single_core = false def single_core = false
def verbose_str = '' def verbose_str = ''
def core_count_str = '$((`nproc` + 1))' def core_count_str = '$((`nproc` + 1))'
def statusCode = 0
if(params.DEBUG) if(params.DEBUG)
@ -95,7 +96,28 @@ if(single_core)
node('test') node('test')
{ {
//currentbuild.result = 'SUCCESS' try
{
checkout()
if(isBuildNeeded)
{
pre_build()
build()
}
}
catch (e)
{
postFailure(e)
}
finally
{
post_build()
}
def checkout()
{
stage('checkout') stage('checkout')
{ {
if(pre_clean) if(pre_clean)
@ -110,8 +132,9 @@ node('test')
isBuildNeeded = true isBuildNeeded = true
} }
} }
}
if(isBuildNeeded) def pre_build()
{ {
stage('pre-build') stage('pre-build')
{ {
@ -119,13 +142,28 @@ node('test')
sh label: 'feeds_update', script: 'cd ' + git_folder + '; ./scripts/feeds update -a' sh label: 'feeds_update', script: 'cd ' + git_folder + '; ./scripts/feeds update -a'
sh label: 'feeds_install', script: 'cd ' + git_folder + '; ./scripts/feeds install -a' sh label: 'feeds_install', script: 'cd ' + git_folder + '; ./scripts/feeds install -a'
} }
}
def build()
{
stage('build') stage('build')
{ {
sh label: 'copy_config', script: 'cp ' + config_path + 'tl_wr841_config ' + git_folder + '/.config' sh label: 'copy_config', script: 'cp ' + config_path + 'tl_wr841_config ' + git_folder + '/.config'
sh label: 'build', script: 'cd ' + git_folder + '; make defconfig; make download; make -j' + core_count_str + verbose_str try
{
statusCode = sh label: 'build', script: 'cd ' + git_folder + '; make defconfig; make download; make -j$((`nproc` + 1))', returnStatus:true
}
catch (e)
{
printDebug(e)
printDebug('multicore build failed -> trying to build verbosely on a single core')
//sh label: 'build', script: 'cd ' + git_folder + '; make defconfig; make download; make -j1 V=sc'
}
finally
{
//empty
}
} }
stage('move_bin_to_ftp') stage('move_bin_to_ftp')
{ {
@ -133,14 +171,12 @@ node('test')
} }
} }
def post_build()
{
if(post_clean) if(post_clean)
{
stage('clean')
{ {
cleanWs() cleanWs()
} }
}
if((!isBuildNeeded && deleteUnbuild)) if((!isBuildNeeded && deleteUnbuild))
{ {
@ -157,5 +193,6 @@ node('test')
//printDebug('NUMBER_after:' + job.nextBuildNumber) //printDebug('NUMBER_after:' + job.nextBuildNumber)
job.save() job.save()
} }
}
} }