rebuilt script structure

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

117
Jenkinsfile vendored
View File

@ -23,6 +23,7 @@ def verbose = false
def single_core = false
def verbose_str = ''
def core_count_str = '$((`nproc` + 1))'
def statusCode = 0
if(params.DEBUG)
@ -94,24 +95,46 @@ if(single_core)
node('test')
{
//currentbuild.result = 'SUCCESS'
stage('checkout')
{
if(pre_clean)
try
{
checkout()
if(isBuildNeeded)
{
cleanWs()
}
sh label: 'checkout_configs', script: 'git clone ' + script_git + ' ' + script_folder
sh label: 'checkout_openwrt', script: 'git clone ' + git_link + ' ' + git_folder
def ret = sh label: 'is_build_needed', script: 'set +x; python ' + scripts_path + 'sftp_test.py -a ' + sftp_host + ' -u ' + sftp_user + ' -p ' + params.SFTP_PASSWD + ' -g ' + git_folder + ' -f ' + scripts_path + known_hosts + ' -l ' + sftp_path + '; set -x', returnStdout: true
if(ret.trim().equalsIgnoreCase('True'))
{
isBuildNeeded = true
pre_build()
build()
}
}
if(isBuildNeeded)
catch (e)
{
postFailure(e)
}
finally
{
post_build()
}
def checkout()
{
stage('checkout')
{
if(pre_clean)
{
cleanWs()
}
sh label: 'checkout_configs', script: 'git clone ' + script_git + ' ' + script_folder
sh label: 'checkout_openwrt', script: 'git clone ' + git_link + ' ' + git_folder
def ret = sh label: 'is_build_needed', script: 'set +x; python ' + scripts_path + 'sftp_test.py -a ' + sftp_host + ' -u ' + sftp_user + ' -p ' + params.SFTP_PASSWD + ' -g ' + git_folder + ' -f ' + scripts_path + known_hosts + ' -l ' + sftp_path + '; set -x', returnStdout: true
if(ret.trim().equalsIgnoreCase('True'))
{
isBuildNeeded = true
}
}
}
def pre_build()
{
stage('pre-build')
{
@ -119,43 +142,57 @@ node('test')
sh label: 'feeds_update', script: 'cd ' + git_folder + '; ./scripts/feeds update -a'
sh label: 'feeds_install', script: 'cd ' + git_folder + '; ./scripts/feeds install -a'
}
}
def build()
{
stage('build')
{
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')
{
sh label: 'copy_binaries', script: 'python ' + scripts_path + 'sftp_test.py -a ' + sftp_host + ' -u ' + sftp_user + ' -p ' + params.SFTP_PASSWD + ' -g ' + git_folder + ' -f ' + scripts_path + known_hosts + ' -l ' + sftp_path + ' -c ' + bin_path
}
}
if(post_clean)
{
stage('clean')
def post_build()
{
if(post_clean)
{
cleanWs()
}
if((!isBuildNeeded && deleteUnbuild))
{
//if no build is needed, then the last build is deleted and the next build number is set to previous build number
def jobName = JOB_NAME
def job = Jenkins.instance.getItem(jobName)
job.getLastBuild().delete()
//printDebug('NUMBER:' + job.nextBuildNumber)
//logger.printInfo('job is getting deleted ' + currentBuild.id.toString())//job.nextBuildNumber)
//job.nextBuildNumber -= 1 //updateNextBuildNumber(job.getNextBuildNumber() - 1) //resetting next build number does not work. if done, the next build start will do nothing
//job.saveNextBuildNumber()
//job.updateNextBuildNumber(job.nextBuildNumber - 1)
//printDebug('NUMBER_after:' + job.nextBuildNumber)
job.save()
}
}
if((!isBuildNeeded && deleteUnbuild))
{
//if no build is needed, then the last build is deleted and the next build number is set to previous build number
def jobName = JOB_NAME
def job = Jenkins.instance.getItem(jobName)
job.getLastBuild().delete()
//printDebug('NUMBER:' + job.nextBuildNumber)
//logger.printInfo('job is getting deleted ' + currentBuild.id.toString())//job.nextBuildNumber)
//job.nextBuildNumber -= 1 //updateNextBuildNumber(job.getNextBuildNumber() - 1) //resetting next build number does not work. if done, the next build start will do nothing
//job.saveNextBuildNumber()
//job.updateNextBuildNumber(job.nextBuildNumber - 1)
//printDebug('NUMBER_after:' + job.nextBuildNumber)
job.save()
}
}