Skip to content

Commit

Permalink
#2: Object-orientify as much as we can
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpinjackie committed Nov 24, 2016
1 parent eab8b4b commit 6106e5d
Showing 1 changed file with 181 additions and 85 deletions.
266 changes: 181 additions & 85 deletions MapGuide-MultiNode.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,183 @@
* - mapguide
* - fdo
*/
node ("master") {
env.PATH = "${env.PATH};C:\\Program Files (x86)\\Subversion\\bin;C:\\Program Files\\doxygen\\bin;C:\\Program Files (x86)\\Graphviz2.38\\bin"
env.ANT_HOME = "C:\\apache-ant-1.9.7"
env.WITH_ARCSDE = "no"

class GlobalConfig {
// The Visual Studio major version. This is used for tagging the mg-desktop artifact and determining the VS setup script
def vs_version = "14"
static String vs_version = "14"
// This is called to set up the VS/MSBuild environment
def vs_init_script = "C:\\Program Files (x86)\\Microsoft Visual C++ Build Tools\\vcbuildtools.bat"
static String vs_init_script = "C:\\Program Files (x86)\\Microsoft Visual C++ Build Tools\\vcbuildtools.bat"
//def vs_init_script = "C:\\Program Files (x86)\\Microsoft Visual Studio ${vs_version}.0\\VC\\vcvarsall.bat"
def release_label = "trunk" // Used for tagging installer artifacts
static String release_label = "trunk" // Used for tagging installer artifacts
//Where the pipeline will grab the mapguide build deps
def mg_dep_root = "C:\\deps\\mapguide\\${release_label}"
static String mg_dep_root = "C:\\deps\\mapguide\\${release_label}"
//Where the pipeline will grab the FDO binaries
def fdo_version = "4.1.0"
def fdo_dep_root = "C:\\deps\\fdo\\${fdo_version}"
static String fdo_version = "4.1.0"
static String fdo_dep_root = "C:\\deps\\fdo\\${fdo_version}"
//Name of the directory where svn will checkout to
def checkout_dir_name = "checkout"
//SVN revision number to be set by polling for the latest rev from the poll url
def svn_rev = "0"
static String checkout_dir_name = "checkout"
//The URL to checkout from
def svn_checkout_url = "https://svn.osgeo.org/mapguide/sandbox/jng/diet_v2/MgDev_Slim"
static String svn_checkout_url = "https://svn.osgeo.org/mapguide/sandbox/jng/diet_v2/MgDev_Slim"
//The URL to poll the latest SVN revision number from. This differs from the poll URL as heavy use of SVN externals
//may mask the true revision number
def svn_poll_url = "https://svn.osgeo.org/mapguide/sandbox/jng/diet_v2/MgDev"
//Java SDK locations
def java_home = [:]
java_home["windows-x86-release"] = "C:\\Program Files (x86)\\Java\\jdk1.6.0_45"
java_home["windows-x64-release"] = "C:\\Program Files\\Java\\jdk1.6.0_45"
java_home["windows-x86-debug"] = "C:\\Program Files (x86)\\Java\\jdk1.6.0_45"
java_home["windows-x64-debug"] = "C:\\Program Files\\Java\\jdk1.6.0_45"
def build_pack = [:]
build_pack["windows-x86-release"] = "mapguide-buildpack-Release-Win32-${release_label}-${env.MG_OEM_BUILDPACK_DATE}.exe"
build_pack["windows-x64-release"] = "mapguide-buildpack-Release-x64-${release_label}-${env.MG_OEM_BUILDPACK_DATE}.exe"
build_pack["windows-x86-debug"] = "mapguide-buildpack-Debug-Win32-${release_label}-${env.MG_OEM_BUILDPACK_DATE}.exe"
build_pack["windows-x64-debug"] = "mapguide-buildpack-Debug-x64-${release_label}-${env.MG_OEM_BUILDPACK_DATE}.exe"
def fdo_sdk = [:]
fdo_sdk["windows-x86-release"] = "Fdo-${fdo_version}-x86.7z"
fdo_sdk["windows-x64-release"] = "Fdo-${fdo_version}-x64.7z"
fdo_sdk["windows-x86-debug"] = "Fdo-${fdo_version}-x86.7z"
fdo_sdk["windows-x64-debug"] = "Fdo-${fdo_version}-x64.7z"
static String svn_poll_url = "https://svn.osgeo.org/mapguide/sandbox/jng/diet_v2/MgDev"
}

/**
* Encapsulates all the key build enviroment settings and build logic
*/
class MgBuildEnvironment implements Serializable {
final String name
final String fdo_sdk
final String build_pack
final String java_home
final String config
final String platform
final String ver_major
final String ver_minor
final String ver_rev
final String vc_init_plat
final String mg_init_script
final String buildpack_date
final String release_label
final String mg_dep_root
final String fdo_dep_root
final String vs_version
final String fdo_version
String svn_rev
MgBuildEnvironment(String name, String config, String platform, String ver_major, String ver_minor, String ver_rev, String buildpack_date, String vs_version, String fdo_version, String release_label, String mg_dep_root, String fdo_dep_root) {
this.ver_major = ver_major
this.ver_minor = ver_minor
this.ver_rev = ver_rev
this.buildpack_date = buildpack_date
this.release_label = release_label
this.mg_dep_root = mg_dep_root
this.fdo_dep_root = fdo_dep_root
this.vs_version = vs_version
this.svn_rev = "0" //SVN revision number to be set by polling for the latest rev from the poll url
this.name = name
this.config = config
this.platform = platform
this.fdo_version = fdo_version
this.fdo_sdk = "Fdo-${this.fdo_version}-${platform}.7z"

this.mg_init_script = "setenvironment.bat"
this.vc_init_plat = "x86"
this.java_home = "C:\\Program Files (x86)\\Java\\jdk1.6.0_45"
def win_plat = "Win32"
if (platform == "x64") {
win_plat = "x64"
this.mg_init_script = "setenvironment64.bat"
this.vc_init_plat = "x86_amd64"
this.java_home = "C:\\Program Files\\Java\\jdk1.6.0_45"
}

this.build_pack = "mapguide-buildpack-${config}-${win_plat}-${this.release_label}-${this.buildpack_date}.exe"
}
String inst_ver() {
return "${this.ver_major}.${this.ver_minor}.${this.ver_rev}.${this.svn_rev}"
}
String installer_name() {
return "MapGuideOpenSource-${this.inst_ver()}-${this.release_label}-${this.config}"
}
String instantsetup_name() {
return "MapGuideOpenSource-${this.inst_ver()}-${this.release_label}-InstantSetup-${this.config}"
}
String mgdesktop_package_name() {
return "mg-desktop-${this.inst_ver()}-net40-vc${this.vs_version}-${this.config}"
}
}

class MgBuildRun implements Serializable {
def scriptEnv
final MgBuildEnvironment buildEnv
MgBuildRun(MgBuildEnvironment buildEnv, scriptEnv) {
this.buildEnv = buildEnv
this.scriptEnv = scriptEnv
}
void build_dep_sanity_check() {
if (!this.scriptEnv.fileExists("${this.buildEnv.mg_dep_root}\\${this.buildEnv.build_pack}")) {
this.scriptEnv.error "Build pack (${this.buildEnv.build_pack}) does not exist at: ${this.buildEnv.mg_dep_root}"
} else {
this.scriptEnv.echo "Sanity - MapGuide OEM buildpack is present"
}
if (!this.scriptEnv.fileExists("${this.buildEnv.fdo_dep_root}\\${this.buildEnv.fdo_sdk}")) {
this.scriptEnv.error "Build pack (${this.buildEnv.fdo_sdk}) does not exist at: ${this.buildEnv.fdo_dep_root}"
} else {
this.scriptEnv.echo "Sanity - FDO binary SDK is present"
}
}
void windows_build(stash) {
this.scriptEnv.dir ("./${this.buildEnv.name}") {
this.scriptEnv.unstash stash
}
this.scriptEnv.echo "Building MapGuide v${this.buildEnv.inst_ver()} (${this.buildEnv.platform}, ${this.buildEnv.config})"
this.scriptEnv.dir ("./${this.buildEnv.name}/build_area") {
if (!this.scriptEnv.fileExists(this.buildEnv.mg_init_script)) {
this.scriptEnv.error "Sanity check fail: Did build_area un-stash properly?"
}
}
}
}

environments = [:]
environments["windows-x86-release"] = new MgBuildEnvironment("windows-x86-release",
"Release",
"x86",
env.MG_VER_MAJOR,
env.MG_VER_MINOR,
env.MG_VER_REV,
env.MG_OEM_BUILDPACK_DATE,
GlobalConfig.vs_version,
GlobalConfig.fdo_version,
GlobalConfig.release_label,
GlobalConfig.mg_dep_root,
GlobalConfig.fdo_dep_root)

environments["windows-x64-release"] = new MgBuildEnvironment("windows-x86-release",
"Release",
"x86",
env.MG_VER_MAJOR,
env.MG_VER_MINOR,
env.MG_VER_REV,
env.MG_OEM_BUILDPACK_DATE,
GlobalConfig.vs_version,
GlobalConfig.fdo_version,
GlobalConfig.release_label,
GlobalConfig.mg_dep_root,
GlobalConfig.fdo_dep_root)

environments["windows-x86-debug"] = new MgBuildEnvironment("windows-x86-release",
"Release",
"x86",
env.MG_VER_MAJOR,
env.MG_VER_MINOR,
env.MG_VER_REV,
env.MG_OEM_BUILDPACK_DATE,
GlobalConfig.vs_version,
GlobalConfig.fdo_version,
GlobalConfig.release_label,
GlobalConfig.mg_dep_root,
GlobalConfig.fdo_dep_root)

environments["windows-x64-debug"] = new MgBuildEnvironment("windows-x86-release",
"Release",
"x86",
env.MG_VER_MAJOR,
env.MG_VER_MINOR,
env.MG_VER_REV,
env.MG_OEM_BUILDPACK_DATE,
GlobalConfig.vs_version,
GlobalConfig.fdo_version,
GlobalConfig.release_label,
GlobalConfig.mg_dep_root,
GlobalConfig.fdo_dep_root)

node ("master") {
env.PATH = "${env.PATH};C:\\Program Files (x86)\\Subversion\\bin;C:\\Program Files\\doxygen\\bin;C:\\Program Files (x86)\\Graphviz2.38\\bin"
env.ANT_HOME = "C:\\apache-ant-1.9.7"
env.WITH_ARCSDE = "no"

echo "MG_SVN_UPDATE is: ${env.MG_SVN_UPDATE}"
stage('SVN checkout') {
//NOTE: Be sure to set the global SVN wc format to 1.6 as the current format (1.8)
Expand All @@ -78,75 +215,50 @@ node ("master") {
//
// Relevant Issue: https://issues.tmatesoft.com/issue/SVNKIT-553
//checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[credentialsId: '', depthOption: 'infinity', ignoreExternalsOption: false, local: './checkout', remote: 'https://svn.osgeo.org/mapguide/sandbox/jng/diet_v2/MgDev_Slim']], workspaceUpdater: [$class: 'UpdateUpdater']])
if (fileExists("./${checkout_dir_name}")) {
if (fileExists("./${GlobalConfig.checkout_dir_name}")) {
if (env.MG_SVN_UPDATE == "true") {
echo "Performing SVN update"
bat "svn update ./${checkout_dir_name}"
bat "svn update ./${GlobalConfig.checkout_dir_name}"
} else {
echo "Skipping SVN update (MG_SVN_UPDATE = ${env.MG_SVN_UPDATE})"
}
} else {
echo "Performing full SVN checkout"
bat "svn co ${svn_checkout_url} ./${checkout_dir_name}"
bat "svn co ${GlobalConfig.svn_checkout_url} ./${GlobalConfig.checkout_dir_name}"
}
echo "Collecting SVN revision"
dir("${checkout_dir_name}\\Installer\\scripts") {
bat "svn info ${svn_poll_url} | perl revnum.pl > svnrev.txt"
svn_rev = readFile("./svnrev.txt").trim()
dir("${GlobalConfig.checkout_dir_name}\\Installer\\scripts") {
bat "svn info ${GlobalConfig.svn_poll_url} | perl revnum.pl > svnrev.txt"
def rev = readFile("./svnrev.txt").trim()
environments.each{ k, v -> v.svn_rev = rev }
}
}
//Now set the appropriate version numbers and artifact names
def mg_ver_major_minor_rev = "${env.MG_VER_MAJOR}.${env.MG_VER_MINOR}.${env.MG_VER_REV}"
def inst_ver = "${mg_ver_major_minor_rev}.${svn_rev}"
def inst_name = [:]
inst_name["windows-x86-release"] = "MapGuideOpenSource-${inst_ver}-${release_label}-x86"
inst_name["windows-x64-release"] = "MapGuideOpenSource-${inst_ver}-${release_label}-x64"
def inst_setup_name = [:]
inst_setup_name["windows-x86-release"] = "MapGuideOpenSource-${inst_ver}-${release_label}-InstantSetup-x86"
inst_setup_name["windows-x64-release"] = "MapGuideOpenSource-${inst_ver}-${release_label}-InstantSetup-x64"
inst_setup_name["windows-x86-debug"] = "MapGuideOpenSource-${inst_ver}-${release_label}-InstantSetup-x86-debug"
inst_setup_name["windows-x64-debug"] = "MapGuideOpenSource-${inst_ver}-${release_label}-InstantSetup-x64-debug"
def mgd_package_name = [:]
mgd_package_name["windows-x86-release"] = "mg-desktop-${inst_ver}-net40-vc${vs_version}-x86"
mgd_package_name["windows-x64-release"] = "mg-desktop-${inst_ver}-net40-vc${vs_version}-x64"
stage('Download required build deps') {
//Verify our build deps exist
parallel (
"windows-x86-release": {
node("windows") {
//Verify our build deps exist
if (!fileExists("${mg_dep_root}\\${build_pack['windows-x86-release']}")) {
error "Build pack (${build_pack['windows-x86-release']}) does not exist at: ${mg_dep_root}"
}
if (!fileExists("${fdo_dep_root}\\${fdo_sdk['windows-x86-release']}")) {
error "Build pack (${fdo_sdk['windows-x86-release']}) does not exist at: ${fdo_dep_root}"
}
new MgBuildRun(environments['windows-x86-release'], this).build_dep_sanity_check()
}
},
"windows-x64-release": {
node("windows") {
//Verify our build deps exist
if (!fileExists("${mg_dep_root}\\${build_pack['windows-x64-release']}")) {
error "Build pack (${build_pack['windows-x64-release']}) does not exist at: ${mg_dep_root}"
}
if (!fileExists("${fdo_dep_root}\\${fdo_sdk['windows-x64-release']}")) {
error "Build pack (${fdo_sdk['windows-x64-release']}) does not exist at: ${fdo_dep_root}"
}
new MgBuildRun(environments['windows-x64-release'], this).build_dep_sanity_check()
}
}
)
//TODO: In an AWS environment, we'd be stashing build deps on S3 and Download them
//should the above fileExists() checks fail
}
stage('Setup build area') {
if (env.MG_CLEAR_BUILD_AREA == "true") {
if (env.MG_CLEAR_BUILD_AREA == "true" || !fileExists("build_area")) {
dir("build_area") {
echo "Current directory is: " + pwd()
echo "Deleting this directory"
deleteDir()
}
echo "SVN exporting to this directory"
bat "svn export ./${checkout_dir_name} build_area --force -q"
bat "svn export ./${GlobalConfig.checkout_dir_name} build_area --force -q"
} else {
echo "Skip clearing build area (MG_CLEAR_BUILD_AREA = ${env.MG_CLEAR_BUILD_AREA})"
}
Expand All @@ -156,28 +268,12 @@ node ("master") {
parallel (
"windows-x86-release": {
node("windows") {
dir ("./windows-x86-release") {
unstash 'svn_build_area_export'
}
echo "Building MapGuide v${inst_ver} (x86, release)"
dir ("./windows-x86-release/build_area") {
if (!fileExists("setenvironment.bat")) {
error "Sanity check fail: Did build_area un-stash properly?"
}
}
new MgBuildRun(environments["windows-x86-release"], this).windows_build('svn_build_area_export')
}
},
"windows-x64-release": {
node("windows") {
dir ("./windows-x64-release") {
unstash 'svn_build_area_export'
}
echo "Building MapGuide v${inst_ver} (x64, release)"
dir ("./windows-x64-release/build_area") {
if (!fileExists("setenvironment64.bat")) {
error "Sanity check fail: Did build_area un-stash properly?"
}
}
new MgBuildRun(environments["windows-x64-release"], this).windows_build('svn_build_area_export')
}
}
)
Expand Down

0 comments on commit 6106e5d

Please sign in to comment.