From 21bc1f7dbe67a301ebef4041b77b73b18d4becc9 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Fri, 19 Oct 2018 12:07:17 +0200 Subject: [PATCH] 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 --- Jenkinsfile | 24 ++++++++++++++++++++---- scripts/jenkins.py | 23 +++++++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0884accab..42bf9b300 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 diff --git a/scripts/jenkins.py b/scripts/jenkins.py index aac82b5e9..849f38a39 100644 --- a/scripts/jenkins.py +++ b/scripts/jenkins.py @@ -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 -w <32|64> -t <' + compiler_help + '> [-d]') + print('jenkins.py -c -w <32|64> -t <' + compiler_help + '> [-d] [-e ]') # 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()