netci.groovy 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // Import the utility functionality.
  6. import jobs.generation.Utilities;
  7. // Grab the github project name passed in
  8. def project = GithubProject
  9. def msbuildTypeMap = [
  10. 'debug':'chk',
  11. 'test':'test',
  12. 'release':'fre'
  13. ]
  14. def dailyRegex = 'dailies'
  15. // ---------------
  16. // HELPER CLOSURES
  17. // ---------------
  18. def CreateBuildTasks = { machine, configTag, buildExtra, testExtra, excludeConfigIf, nonDefaultTaskSetup ->
  19. [true, false].each { isPR ->
  20. ['x86', 'x64', 'arm'].each { buildArch ->
  21. ['debug', 'test', 'release'].each { buildType ->
  22. if (excludeConfigIf && excludeConfigIf(isPR, buildArch, buildType)) {
  23. return // early exit: we don't want to create a job for this configuration
  24. }
  25. def config = "${buildArch}_${buildType}"
  26. config = (configTag == null) ? config : "${configTag}_${config}"
  27. // params: Project, BaseTaskName, IsPullRequest (appends '_prtest')
  28. def jobName = Utilities.getFullJobName(project, config, isPR)
  29. def testableConfig = buildType in ['debug', 'test'] && buildArch != 'arm'
  30. def analysisConfig = buildType in ['release']
  31. def buildScript = "call jenkins.buildone.cmd ${buildArch} ${buildType}"
  32. buildScript += buildExtra ?: ''
  33. buildScript += analysisConfig ? ' "/p:runcodeanalysis=true"' : ''
  34. def testScript = "call jenkins.testone.cmd ${buildArch} ${buildType}"
  35. testScript += testExtra ?: ''
  36. def analysisScript = ".\\Build\\scripts\\check_prefast_error.ps1 . CodeAnalysis.err"
  37. def newJob = job(jobName) {
  38. // This opens the set of build steps that will be run.
  39. // This looks strange, but it is actually a method call, with a
  40. // closure as a param, since Groovy allows method calls without parens.
  41. // (Compare with '.each' method used above.)
  42. steps {
  43. batchFile(buildScript) // run the parameter as if it were a batch file
  44. if (testableConfig) {
  45. batchFile(testScript)
  46. }
  47. if (analysisConfig) {
  48. powerShell(analysisScript)
  49. }
  50. }
  51. }
  52. Utilities.setMachineAffinity(newJob, machine)
  53. def msbuildType = msbuildTypeMap.get(buildType)
  54. def msbuildFlavor = "build_${buildArch}${msbuildType}"
  55. def archivalString = "test/${msbuildFlavor}.*,test/logs/**"
  56. archivalString += analysisConfig ? ',CodeAnalysis.err' : ''
  57. Utilities.addArchival(newJob, archivalString,
  58. '', // no exclusions from archival
  59. false, // doNotFailIfNothingArchived=false ~= failIfNothingArchived
  60. false) // archiveOnlyIfSuccessful=false ~= archiveAlways
  61. if (nonDefaultTaskSetup == null)
  62. {
  63. // This call performs remaining common job setup on the newly created job.
  64. // This is used most commonly for simple inner loop testing.
  65. // It does the following:
  66. // 1. Sets up source control for the project.
  67. // 2. Adds a push trigger if the job is a PR job
  68. // 3. Adds a github PR trigger if the job is a PR job.
  69. // The optional context (label that you see on github in the PR checks) is added.
  70. // If not provided the context defaults to the job name.
  71. // 4. Adds standard options for build retention and timeouts
  72. // 5. Adds standard parameters for PR and push jobs.
  73. // These allow PR jobs to be used for simple private testing, for instance.
  74. // See the documentation for this function to see additional optional parameters.
  75. Utilities.simpleInnerLoopJobSetup(newJob, project, isPR, "Windows ${config}")
  76. }
  77. else
  78. {
  79. Utilities.standardJobSetup(newJob, project, isPR)
  80. nonDefaultTaskSetup(newJob, isPR, config)
  81. }
  82. }
  83. }
  84. }
  85. }
  86. def DailyBuildTaskSetup = { newJob, isPR, triggerName, groupRegex ->
  87. // The addition of triggers makes the job non-default in GitHub.
  88. if (isPR) {
  89. def triggerRegex = "(${dailyRegex}|${groupRegex}|${triggerName})"
  90. Utilities.addGithubPRTrigger(newJob,
  91. triggerName, // GitHub task name
  92. "(?i).*test\\W+${triggerRegex}.*")
  93. } else {
  94. Utilities.addPeriodicTrigger(newJob, '@daily')
  95. }
  96. }
  97. def CreateStyleCheckTasks = { taskString, taskName, checkName ->
  98. [true, false].each { isPR ->
  99. def jobName = Utilities.getFullJobName(project, taskName, isPR)
  100. def newJob = job(jobName) {
  101. steps {
  102. shell(taskString)
  103. }
  104. }
  105. Utilities.simpleInnerLoopJobSetup(newJob, project, isPR, checkName)
  106. Utilities.setMachineAffinity(newJob, 'Ubuntu14.04', 'latest-or-auto')
  107. }
  108. }
  109. // ----------------
  110. // INNER LOOP TASKS
  111. // ----------------
  112. CreateBuildTasks('Windows_NT', null, null, null, null, null)
  113. // -----------------
  114. // DAILY BUILD TASKS
  115. // -----------------
  116. // build and test on Windows 7 with VS 2013 (Dev12/MsBuild12)
  117. CreateBuildTasks('Windows 7', 'daily_dev12', ' msbuild12', ' -win7',
  118. /* excludeConfigIf */ { isPR, buildArch, buildType -> (buildArch == 'arm') },
  119. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  120. DailyBuildTaskSetup(newJob, isPR,
  121. "Windows 7 ${config}",
  122. '(win(dows)?\\s*7|(dev|msbuild)\\s*12)')})
  123. // build and test on the usual configuration (VS 2015) with -includeSlow
  124. CreateBuildTasks('Windows_NT', 'daily_slow', null, ' -includeSlow', null,
  125. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  126. DailyBuildTaskSetup(newJob, isPR,
  127. "Windows ${config}",
  128. '(slow\\s*(tests)?)')})
  129. // build and test on the usual configuration (VS 2015) with JIT disabled
  130. CreateBuildTasks('Windows_NT', 'daily_disablejit', ' "/p:BuildJIT=false"', ' -disablejit', null,
  131. /* nonDefaultTaskSetup */ { newJob, isPR, config ->
  132. DailyBuildTaskSetup(newJob, isPR,
  133. "Windows ${config}",
  134. '(disablejit|nojit)')})
  135. // ----------------
  136. // CODE STYLE TASKS
  137. // ----------------
  138. CreateStyleCheckTasks('./jenkins.check_eol.sh', 'ubuntu_check_eol', 'EOL Check')
  139. CreateStyleCheckTasks('./jenkins.check_copyright.sh', 'ubuntu_check_copyright', 'Copyright Check')