Set end of live date in Jenkins build

Depending on the branch, we override the end of live date relative in month
from the build time.
develop/ builds expire in 6 month
release/ builds expire in 12 month
all others expire in 3 month.

ref T319
This commit is contained in:
Roland Winklmeier
2018-10-19 12:07:17 +02:00
committed by Klaus Basan
parent 3770b02ea7
commit 21bc1f7dbe
2 changed files with 39 additions and 8 deletions

24
Jenkinsfile vendored
View File

@@ -12,10 +12,11 @@ builders['Build swift Linux'] = {
}
stage('Linux Build') {
def eolInMonth = 6
withEnv(['BITROCK_BUILDER=/opt/installbuilder/bin/builder', 'BITROCK_CUSTOMIZE=/opt/installbuilder/autoupdate/bin/customize.run']) {
sh '''
cp ~/vatsim.pri.official mkspecs/features/vatsim.pri
python3 -u scripts/jenkins.py -w 64 -t gcc -d -j 2
python3 -u scripts/jenkins.py -w 64 -t gcc -d -j 2 -e ''' + getEolInMonth() + '''
'''
}
@@ -62,7 +63,7 @@ builders['Build swift MacOS'] = {
withEnv(['PATH+LOCAL=/usr/local/bin', 'BITROCK_BUILDER=/Applications/BitRockInstallBuilderQt/bin/builder', 'BITROCK_CUSTOMIZE=/Applications/BitRockInstallBuilderQt/autoupdate/bin/customize.sh']) {
sh '''
cp ~/vatsim.pri.official mkspecs/features/vatsim.pri
python -u scripts/jenkins.py -w 64 -t clang -d -j2
python -u scripts/jenkins.py -w 64 -t clang -d -j2 -e ''' + getEolInMonth() + '''
'''
}
@@ -101,7 +102,7 @@ builders['Build swift Win32'] = {
stage('Win32 Build') {
bat '''
copy /Y c:\\var\\vatsim.pri.official mkspecs\\features\\vatsim.pri
python -u scripts/jenkins.py -w 32 -t msvc -d
python -u scripts/jenkins.py -w 32 -t msvc -d -e ''' + getEolInMonth() + '''
'''
warnings consoleParsers: [[parserName: 'MSBuild']], unstableTotalAll: '0'
@@ -140,7 +141,7 @@ builders['Build swift Win64'] = {
stage('Win64 Build') {
bat '''
copy /Y c:\\var\\vatsim.pri.official mkspecs\\features\\vatsim.pri
python -u scripts/jenkins.py -w 64 -t msvc -d
python -u scripts/jenkins.py -w 64 -t msvc -d -e ''' + getEolInMonth() + '''
'''
warnings consoleParsers: [[parserName: 'MSBuild']], unstableTotalAll: '0'
@@ -298,6 +299,21 @@ def notifySlack(nodeName, buildStatus = 'STARTED') {
slackSend (color: colorCode, message: summary)
}
def getEolInMonth() {
def regexDevBranch = /develop\/\d.\d.\d/
def regexReleaseBranch = /^release\/\d.\d/
if (BRANCH_NAME ==~ regexDevBranch) {
// 6 month for dev builds
return 6
} else if(BRANCH_NAME ==~ regexReleaseBranch) {
// 12 month currently for release builds. That will be removed in future.
return 12
} else {
// 3 month for everything else
return 3
}
}
def killDBusDaemon() {
bat '''
tasklist /FI "IMAGENAME eq dbus-daemon.exe" 2>NUL | find /I /N "dbus-daemon.exe">NUL

View File

@@ -8,6 +8,7 @@
# including this file, may be copied, modified, propagated, or distributed except according to the terms
# contained in the LICENSE file.
from datetime import date
import getopt
import multiprocessing
import os
@@ -44,7 +45,7 @@ class Builder:
shared_path = os.path.abspath(os.path.join(source_path, 'resources', 'share'))
datastore.update_shared(host, datastore_version, shared_path)
def build(self, jobs, dev_build):
def build(self, jobs, dev_build, eolInMonth):
"""
Run the build itself. Pass dev_build=True to enable a dev build
"""
@@ -53,9 +54,20 @@ class Builder:
if not os.path.isdir(build_path):
os.makedirs(build_path)
os.chdir(build_path)
qmake_call = ['qmake']
if dev_build:
qmake_call += ['"BLACK_CONFIG+=SwiftDevBranch"']
if eolInMonth > 0:
eolYear = date.today().year
eolMonth = date.today().month + eolInMonth
eolYear = eolYear + ( eolMonth / 12 )
eolMonth = eolMonth % 12
eolDate = date(int(eolYear), int(eolMonth), 1)
print('Setting EOL date to ' + eolDate.strftime('%Y%m%d'))
qmake_call += ['BLACK_EOL=' + eolDate.strftime('%Y%m%d')]
qmake_call += ['-r', os.pardir]
subprocess.check_call(qmake_call, env=dict(os.environ))
@@ -372,7 +384,7 @@ def print_help():
'Windows': ['msvc', 'mingw']
}
compiler_help = '|'.join(supported_compilers[platform.system()])
print('jenkins.py -c <config file> -w <32|64> -t <' + compiler_help + '> [-d]')
print('jenkins.py -c <config file> -w <32|64> -t <' + compiler_help + '> [-d] [-e <end of life in month>]')
# Entry point if called as a standalone program
@@ -383,9 +395,10 @@ def main(argv):
dev_build = False
jobs = None
upload_symbols = False
eolInMonth = 0
try:
opts, args = getopt.getopt(argv, 'hc:w:t:j:du', ['config=', 'wordsize=', 'toolchain=', 'jobs=', 'dev', 'upload'])
opts, args = getopt.getopt(argv, 'hc:w:t:j:due:', ['config=', 'wordsize=', 'toolchain=', 'jobs=', 'dev', 'upload', 'eol'])
except getopt.GetoptError:
print_help()
sys.exit(2)
@@ -413,6 +426,8 @@ def main(argv):
dev_build = True
elif opt in ('-u', '--upload'):
upload_symbols = True
elif opt in ('-e', '--eol'):
eolInMonth = int(arg)
if word_size not in ['32', '64']:
print('Unsupported word size. Choose 32 or 64')
@@ -435,7 +450,7 @@ def main(argv):
builder = builders[platform.system()][tool_chain](config_file, word_size)
builder.prepare()
builder.build(jobs, dev_build)
builder.build(jobs, dev_build, eolInMonth)
builder.checks()
builder.install()
builder.publish()