├── .gitignore ├── LICENSE ├── README.md ├── data └── repolist.txt ├── docs ├── CI-CLASSIC.md ├── CI-ONBOARDING.md ├── CI-PIPELINES.md ├── END-USER-TASKS.md ├── SYSTEM-OVERVIEW.md ├── sample-classic-declaration.groovy └── sample-pipeline-declaration.groovy ├── management └── nodes │ ├── Capture-And-Deploy-VM.ps1 │ ├── Capture-VM.ps1 │ ├── Check-All-Images.ps1 │ ├── Check-Image.ps1 │ ├── Clean-Deployments.ps1 │ ├── Clean-Resource-Group.ps1 │ ├── Create-VM.ps1 │ ├── Delete-VM.ps1 │ ├── Deploy-Image.ps1 │ ├── Deploy-VHD.ps1 │ ├── Get-Available-Resource-Groups.ps1 │ ├── Get-Connection-Info.ps1 │ ├── Get-Images.ps1 │ ├── Get-Resource-Group.ps1 │ ├── Get-Storage-Context.ps1 │ ├── Get-Target-Storage-Accounts.ps1 │ ├── Get-VHD-Location.ps1 │ ├── Images.csv │ ├── Migrate-Image-From-Classic.ps1 │ ├── Parse-VHD-Uri.ps1 │ ├── ResourceGroups.txt │ ├── StorageAccounts.txt │ ├── reboot │ ├── README.md │ ├── osx │ │ └── osx_python.sh │ ├── tripleboot-reboot-script.py │ ├── ubuntu │ │ ├── mount_cmd.sh │ │ └── ubuntu_python.sh │ └── windows │ │ ├── create_reboot_task.bat │ │ ├── create_reboot_task.xml │ │ ├── launch_jenkins_task.bat │ │ ├── launch_jenkins_task.xml │ │ ├── reboot_script.bat │ │ └── win10_python.bat │ └── startupScripts │ ├── centos71-20160609-1-outer.sh │ ├── centos71-20160929.sh │ ├── centos71-20170216-outer.sh │ ├── centos71-20170216.sh │ ├── deb82-20160323-outer.sh │ ├── deb82-20160323.sh │ ├── deb84-20160623-outer.sh │ ├── deb84-20160623.sh │ ├── deb84-20170214-outer.sh │ ├── deb84-20170214.sh │ ├── fedora23-20160622-outer.sh │ ├── fedora23-20160622.sh │ ├── fedora24-20161024-outer.sh │ ├── fedora24-20161024.sh │ ├── fedora24-20170420-outer.sh │ ├── fedora24-20170420.sh │ ├── freebsd-20161025.sh │ ├── rhel72-20160211.sh │ ├── rhel72-20160412-1-outer.sh │ ├── rhel72-20170525.sh │ ├── suse132-20160315-outer.sh │ ├── suse132-20160315.sh │ ├── suse421-20160920-outer.sh │ ├── suse421-20160920.sh │ ├── suse421-20170216-outer.sh │ ├── suse421-20170216.sh │ ├── ubuntu1404-20160206-outer.sh │ ├── ubuntu1404-20160211-1-internal.sh │ ├── ubuntu1404-20160211-1.sh │ ├── ubuntu1404-20160818.sh │ ├── ubuntu1404-20161019.sh │ ├── ubuntu1404-20161020.sh │ ├── ubuntu1404-20170109.sh │ ├── ubuntu1404-20170118.sh │ ├── ubuntu1404-20170728-outer.sh │ ├── ubuntu1404-20170728.sh │ ├── ubuntu1404-20170821.sh │ ├── ubuntu1404-20170925.sh │ ├── ubuntu1404-20180321.sh │ ├── ubuntu1510-20160307-outer.sh │ ├── ubuntu1510-20160307.sh │ ├── ubuntu1604-20160510-outer.sh │ ├── ubuntu1604-20160510.sh │ ├── ubuntu1604-20160803.sh │ ├── ubuntu1604-20170109.sh │ ├── ubuntu1604-20170216-outer-outer.sh │ ├── ubuntu1604-20170216-outer.sh │ ├── ubuntu1610-20160927-outer.sh │ ├── ubuntu1610-20160927.sh │ ├── ubuntu1610-20170216-outer.sh │ ├── ubuntu1610-20170216.sh │ ├── win2008-20161026.ps1 │ ├── win2008-20161104.ps1 │ ├── win2008-20170302.ps1 │ ├── win2008-20170303.ps1 │ ├── win2012-20160506.ps1 │ ├── win2012-20160707-internal.ps1 │ ├── win2012-20160707.ps1 │ ├── win2012-20160824-elevated.ps1 │ ├── win2012-20160824.ps1 │ ├── win2012-20161027.ps1 │ ├── win2012-20170302.ps1 │ ├── win2012-20170303.ps1 │ ├── win2012-20170307.ps1 │ ├── win2012-20170328.ps1 │ ├── win2012-20170427-elevated.ps1 │ ├── win2012-20170427.ps1 │ ├── win2012-20170531-elevated.ps1 │ ├── win2012-20170531.ps1 │ ├── win2012-20170608-elevated.ps1 │ ├── win2012-20170608.ps1 │ ├── win2012-20170809-elevated.ps1 │ ├── win2012-20170810.ps1 │ ├── win2012-20170929-elevated.ps1 │ ├── win2012-20170929.ps1 │ ├── win2012-20171027.ps1 │ ├── win2016-20160825.ps1 │ ├── win2016-20161018-1.ps1 │ ├── win2016-20170113-internal.ps1 │ ├── win2016-20170113.ps1 │ ├── win2016-20170128-internal.ps1 │ ├── win2016-20170128.ps1 │ ├── win2016-20170207-internal.ps1 │ ├── win2016-20170207.ps1 │ ├── win2016-20170213-internal.ps1 │ ├── win2016-20170213.ps1 │ ├── win2016-20170214-internal.ps1 │ ├── win2016-20170214.ps1 │ ├── win2016-20170302.ps1 │ ├── win2016-20170307-internal.ps1 │ ├── win2016-20170307.ps1 │ ├── win2016-20170427-1-internal.ps1 │ ├── win2016-20170427-1.ps1 │ ├── win2016-20170427-internal.ps1 │ ├── win2016-20170427.ps1 │ ├── win2016-20170510-internal.ps1 │ ├── win2016-20170510.ps1 │ ├── win2016-20170531-internal.ps1 │ ├── win2016-20170531.ps1 │ ├── win2016-20170613-internal.ps1 │ ├── win2016-20170613.ps1 │ ├── win2016-20170712.ps1 │ ├── win2016-20170717-internal.ps1 │ ├── win2016-20170717.ps1 │ ├── win2016-20170731-internal.ps1 │ ├── win2016-20170731.ps1 │ ├── win2016-20170802-internal.ps1 │ ├── win2016-20170802.ps1 │ ├── win2016-20170814-internal.ps1 │ ├── win2016-20170814.ps1 │ ├── win2016-20170919-internal.ps1 │ ├── win2016-20170919.ps1 │ ├── win2016-20170921.ps1 │ ├── win2016-20171014.ps1 │ ├── win2016-20180117.ps1 │ ├── win2016-base-internal.ps1 │ └── win2016-base.ps1 ├── poke └── pokefile ├── scripts ├── disable_jobs_in_folder.groovy ├── disable_swap_space_monitor.groovy ├── generator_cleaner.groovy ├── populate-azure-vm-templates.groovy ├── queue-failed-generators.groovy ├── queue-generators-older.groovy ├── remove_offline_nodes.groovy ├── show-running-prs.groovy ├── system_cleaner.groovy ├── take_offline.groovy └── workspace_cleaner.groovy ├── src ├── jobs │ └── generation │ │ ├── ArchivalSettings.groovy │ │ ├── GenerationSettings.groovy │ │ ├── JobReport.groovy │ │ ├── MetaGenerator.groovy │ │ ├── PostGen.groovy │ │ ├── PreGen.groovy │ │ ├── RootGenerator.groovy │ │ ├── SummaryBuilder.groovy │ │ ├── TriggerBuilder.groovy │ │ └── Utilities.groovy └── org │ └── dotnet │ ├── ci │ ├── pipelines │ │ ├── Pipeline.groovy │ │ └── scm │ │ │ ├── GithubPipelineScm.groovy │ │ │ ├── PipelineScm.groovy │ │ │ └── VSTSPipelineScm.groovy │ ├── triggers │ │ ├── GenericTriggerBuilder.groovy │ │ ├── GithubTriggerBuilder.groovy │ │ ├── TriggerBuilder.groovy │ │ └── VSTSTriggerBuilder.groovy │ └── util │ │ ├── Agents.groovy │ │ └── Constants.groovy │ └── helix │ ├── HelixEvent.groovy │ ├── HelixEventData.groovy │ ├── HelixEventSender.groovy │ ├── HelixTraceListener.groovy │ ├── IHelixEventSender.groovy │ └── NoopSender.groovy ├── tests ├── dsl │ ├── pipeline_manual_trigger.groovy │ ├── pipeline_periodic_trigger.groovy │ ├── pipeline_pr_trigger.groovy │ ├── pipeline_simple_push_trigger.groovy │ ├── simple_job_check_out_to_subdir.groovy │ ├── simple_traditional_job.groovy │ ├── test_repro_job.groovy │ ├── traditional_job_with_paren_in_name.groovy │ └── utilities_tests.groovy └── pipeline │ ├── pipeline-tests.groovy │ └── tests.groovy └── vars ├── addSummaryLink.groovy ├── archiveLogs.groovy ├── checkoutRepo.groovy ├── createSender.groovy ├── createSenderMap.groovy ├── generateRandomUUID.groovy ├── getBranch.groovy ├── getBuildNumber.groovy ├── getCommit.groovy ├── getCommitForDir.groovy ├── getCommitForPR.groovy ├── getEncodedUrl.groovy ├── getHelixSource.groovy ├── getLogFolder.groovy ├── getOrganization.groovy ├── getPRNumber.groovy ├── getRepo.groovy ├── getSenderMap.groovy ├── getUser.groovy ├── getUserEmail.groovy ├── getVersionControlLocation.groovy ├── isNullOrEmpty.groovy ├── isPR.groovy ├── loadPipeline.groovy ├── makeLogFolder.groovy ├── sendEvent.groovy ├── setPRStatus.groovy ├── simpleDockerNode.groovy ├── simpleNode.groovy └── waitForHelixRuns.groovy /.gitignore: -------------------------------------------------------------------------------- 1 | *.orig 2 | *.rej 3 | .vscode -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Matt Mitchell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # .NET CI Repository 2 | 3 | Contains documentation and some implementation functionality for the .NET CI system. 4 | 5 | ## Getting started and need to onboard your project? 6 | 7 | Start [here.](docs/CI-ONBOARDING.md) 8 | 9 | ## Looking for the repo list to add another branch for your project? 10 | 11 | Go [here.](data/repolist.txt) 12 | 13 | ## Looking for information on how to write your jobs 14 | 15 | * [Pipeline jobs(new)](docs/CI-PIPELINES.md) 16 | * [Classic jobs](docs/CI-CLASSIC.md) 17 | 18 | ## Looking for a general system overview? 19 | 20 | Look [here.](docs/SYSTEM-OVERVIEW.md) -------------------------------------------------------------------------------- /docs/CI-ONBOARDING.md: -------------------------------------------------------------------------------- 1 | ## Onboarding onto .NET CI 2 | 3 | Below contains information on how to onboard your project onto Jenkins. 4 | 5 | 1. Send a PR to dotnet-ci adding your repo to data\repolist.txt. The server (dotnet-ci, dotnet-ci2 or dotnet-ci3) is specified in the line. Typically dotnet-ci is used, 6 | 2. Ensure your repo is accessible by @dotnet-bot and @mmitche. 7 | 3. Configure web hooks for the CI. You need two entries: 8 | * A GitHub webhook for push events - Go into the repo settings, click "Webhooks", then click "Add webhook". 9 | - Payload URL: https://ci.dot.net/github-webhook/ (For projects on dotnet-ci2, use https://ci2.dot.net/github-webhook/, and for projects on dotnet-ci3, use https://ci3.dot.net/github-webhook/) 10 | - Content type: application/x-www-form-urlencoded 11 | - "Just send me the push event" 12 | * A GitHub webhook for pull request events - Go into the repo settings, click "Webhooks", then click "Add webhook". 13 | - Payload URL: https://ci.dot.net/ghprbhook/ (For projects on dotnet-ci2, use https://ci2.dot.net/ghprbhook/, and for projects on dotnet-ci3, use https://ci3.dot.net/ghprbhook/) 14 | - Content type: application/x-www-form-urlencoded 15 | - Shared secret - GitHubPRBuilderSharedSecret from DCIKeyVault 16 | - "Let me select individual events" 17 | - Pull request 18 | - Issue comment 19 | 4. Similarly private repos on VSTS also need two entries: 20 | * A VSTS webhook for push events - Go into the repo settings, click "Service Hooks", then click "Create a new subscription..." ("+" icon) 21 | - Service: Jenkins, then click "Next" 22 | - Trigger on this type of event: "Code pushed" 23 | - Repository: your repo selected from the dropdown list (for example "DotNet-CI-Trusted"), then click "Next" 24 | - Perform this action: "Trigger Git build" 25 | - Jenkins base URL: https://dotnet-vsts.westus2.cloudapp.azure.com 26 | - User name: {youralias}@microsoft.com 27 | - User API token (or password): Go to https://dotnet-vsts.westus2.cloudapp.azure.com/user/{youralias}@microsoft.com/configure, click "SHOW API TOKEN...", paste "API Token" in. 28 | - Integration level: "TFS plugin for Jenkins", then click "Test" and "Finish". 29 | * A VSTS webhook for PR events - Go into the repo settings, click "Service Hooks", then click "Create a new subscription..." ("+" icon) 30 | - Service: Jenkins, then click "Next" 31 | - Trigger on this type of event: "Pull request merge commit created" 32 | - Repository: your repo selected from the dropdown list (for example "DotNet-CI-Trusted"), then click "Next" 33 | - Perform this action: "Trigger Git build" 34 | - Jenkins base URL: https://dotnet-vsts.westus2.cloudapp.azure.com 35 | - User name: {youralias}@microsoft.com 36 | - User API token (or password): Go to https://dotnet-vsts.westus2.cloudapp.azure.com/user/{youralias}@microsoft.com/configure, click "SHOW API TOKEN...", paste "API Token" in. 37 | - Integration level: "TFS plugin for Jenkins", then click "Test" and "Finish". 38 | 4. Create a file called netci.groovy in root of your repo in the target branch (this could also be named something different based on the line in the repolist.txt file). 39 | 5. Write your CI definition 40 | * [Pipeline jobs (new)](CI-PIPELINES.md) 41 | * [Classic jobs](CI-CLASSIC.md) 42 | 6. PR the netci.groovy file, /cc @dotnet/dnceng for review and comment "test ci please" to the PR thread. 43 | 7. Once the test generation completes, you may examine the jobs for correctness by clicking on the Details link of the job. 44 | -------------------------------------------------------------------------------- /docs/END-USER-TASKS.md: -------------------------------------------------------------------------------- 1 | # End User Tasks 2 | 3 | This document describes various tasks end users of the system may want to perform. For information on writing CI scripting, see WRITING-NETCI.md 4 | 5 | ## The Github comment system and CI 6 | 7 | Today, the primary way that users interact with the CI system doing pull requests is through the comment system. Comments are fed back into the CI system, which then looks to see whether the commented phrases matches known sets of phrases which signal different things. Most of the time these signals are job triggers. 8 | 9 | While not required, when commenting to interact with the CI system, it's best practice to prefix your comment with '@dotnet-bot ' to avoid confusion. For example, '@dotnet-bot test this please'. Most phrases are not case, space, or line sensitive, and can be combined with other phrases in the same commment. 10 | 11 | ## Re-Queuing PR testing 12 | 13 | PR testing might need to be re-queued for various reasons: 14 | 15 | * A necessary fix got merged and you want to ensure your PR now passes 16 | * Infrastructure issues (disk space, connection, etc.) 17 | * Transient test issues. 18 | 19 | ** First and foremost, before you decide to re-queue testing, examine whether the failure you are trying to clear should instead be investigated and fixed. Mashing retest phrases until you get what you want (green) doesn't help anyone in the long term** 20 | 21 | There are two primary ways to do re-testing: general re-test and specific re-tests. A general re-test will re-queue all jobs that run by default, while a specific test will only run those jobs associated with the phrase. 22 | 23 | * 'test this' tells the CI system to rerun all testing associated by default with the PR (optional legs will not automatically re-queue). At the time of writing, this will **not** cancel previous jobs, if any are running, though that functionality is in the works. 24 | Example: @dotnet-bot test this please 25 | * 'test ' tells the CI system to re-queue a job that was run by default. If a created job was given no custom test phrase, the pull request context phrase (for instance, 'Ubuntu x64 Checked Build and Test') will automatically be associated with the job. Commenting test followed by the context phrase will requeue just that job. Again, this phrase is case insensitive. 26 | Example: @dotnet-bot test Ubuntu x64 Checked Build and Test please 27 | 28 | ## Queuing optional testing 29 | 30 | There is LOTS of optional testing in Jenkins. In general, most jobs that are created have a way to run them at PR time. For coreclr, this might translate out to hundreds of potential jobs. You can choose testing beyond the defaults to suit your PR's needs. At the time of writing, there is no formal method of finding all the test phrases besides looking at the netci.groovy file in a repo. The addGithubPullRequestTrigger (and addGithubPullRequestTriggerForBranch) take an optional parameter after the context which indicates the test phrase. If the test phrase is supplied, commenting that phrase will queue the job. 31 | 32 | Example: 33 | 34 | Utilities.addGithubPRTrigger(job, "${os} ${architecture} ${configuration} Build", '(?i).*test\\W+suse.*') 35 | 36 | In this, saying 'test suse' Will queue up OpenSUSE testing. Presumably in this case, the same test phrase was used across all configurations and architectures, so each job that was given that phrase will be queued. 37 | 38 | In the future, there are plans for easy ways to determine what the phrases are, or avoid them altogether where possible. 39 | -------------------------------------------------------------------------------- /docs/sample-classic-declaration.groovy: -------------------------------------------------------------------------------- 1 | // Import the utility functionality. 2 | import jobs.generation.Utilities; 3 | 4 | // Defines a the new of the repo, used elsewhere in the file 5 | def project = QualifiedRepoName 6 | def branch = BranchName 7 | 8 | // Generate the builds for debug and release, commit and PRJob 9 | [true, false].each { isPR -> // Defines a closure over true and false, value assigned to isPR 10 | ['Debug', 'Release'].each { configuration -> 11 | 12 | // Determine the name for the new job. The first parameter is the project, 13 | // the second parameter is the base name for the job, and the last parameter 14 | // is a boolean indicating whether the job will be a PR job. If true, the 15 | // suffix _prtest will be appended. 16 | def newJobName = Utilities.getFullJobName(project, configuration, isPR) 17 | 18 | // Define build string 19 | def buildString = """call \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsDevCmd.bat\" && build.cmd ${configuration}""" 20 | 21 | // Create a new job with the specified name. The brace opens a new closure 22 | // and calls made within that closure apply to the newly created job. 23 | def newJob = job(newJobName) { 24 | // This opens the set of build steps that will be run. 25 | steps { 26 | // Indicates that a batch script should be run with the build string (see above) 27 | // Also available is: 28 | // shell (for unix scripting) 29 | batchFile(buildString) 30 | } 31 | } 32 | 33 | Utilities.setMachineAffinity(newJob, 'Windows_NT', 'latest-or-auto') 34 | 35 | // This call performs remaining common job setup on the newly created job. 36 | // It does the following: 37 | // 1. Sets up source control for the project. 38 | // 2. Adds standard options for build retention and timeouts 39 | // 3. Adds standard parameters for PR and push jobs. 40 | // These allow PR jobs to be used for simple private testing, for instance. 41 | // See the documentation for this function to see additional optional parameters. 42 | Utilities.standardJobSetup(newJob, project, isPR, "refs/heads/${branch}") 43 | 44 | // The following two calls add triggers for push and PR jobs 45 | // In Github, the PR trigger will appear as "Windows Debug" and "Windows Release" and will be run 46 | // by default 47 | if (isPR) { 48 | Utilities.addGithubPRTriggerForBranch(newJob, branch, "Windows ${configuration}") 49 | } 50 | else { 51 | Utilities.addGithubPushTrigger(newJob) 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /docs/sample-pipeline-declaration.groovy: -------------------------------------------------------------------------------- 1 | // Import the pipeline declaration classes. 2 | import org.dotnet.ci.pipelines.Pipeline 3 | 4 | // Declare a new pipeline. 5 | def windowsPipeline = Pipeline.createPipeline(this, 'windows-pipeline.groovy') 6 | 7 | // Over the array of 'Debug' and 'Release' configurations, generate a pipeline 8 | // job that runs windows-pipeline on each push, passing in the parameter 9 | // 'Configuration' with the value of 'configuration' 10 | ['Debug', 'Release'].each { configuration -> 11 | windowsPipeline.triggerPipelineOnPush(['Configuration':configuration]) 12 | } 13 | 14 | // Over the array of 'Debug' and 'Release' configurations, generate a pipeline 15 | // job that runs linux-pipeline.groovy on each PR, passing in the parameter 16 | // 'Configuration' with the value of 'configuration' 17 | def linuxPipeline = Pipeline.createPipeline(this, 'linux-pipeline.groovy') 18 | // Pass Debug/Release configuration 19 | ['Debug', 'Release'].each { configuration -> 20 | linuxPipeline.triggerPipelineOnEveryPR(['Configuration':configuration]) 21 | } -------------------------------------------------------------------------------- /management/nodes/Capture-And-Deploy-VM.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Capture-And-Deploy-VM 4 | .DESCRIPTION 5 | Captures a VM image for use, deploys it to the necessary stoirage accounts, and pends a change to the image list 6 | .PARAMETER ImageBaseName 7 | Base name for the final image name. 8 | .PARAMETER VMName 9 | VM Name to capture 10 | .PARAMETER ResourceGroupName 11 | Resource group name containing the VM (if not specified, VM is located in the standard RGs) 12 | #> 13 | 14 | param ( 15 | [ValidateSet('ubuntu1404','ubuntu1504', 'ubuntu1604', 'ubuntu1610', 'win2012', 'win2016', 'centos71', 'rhel72', 'freebsd', 'suse132', 'suse421', 'deb82', 'fedora23', 'deb84')] 16 | [string]$ImageBaseName = $(Read-Host -prompt "VM image base name of image to capture."), 17 | [string]$VMName = $(Read-Host -prompt "VM name to capture"), 18 | [switch]$ForceShutdown = $false, 19 | [string]$TargetContainer = 'dotnetci', 20 | [string]$Suffix = $null 21 | ) 22 | 23 | # Capture the VM 24 | 25 | $imageProperties = .\Capture-VM -ImageBaseName $ImageBaseName -VMName $VMName -ForceShutdown $ForceShutdown -TargetContainer $TargetContainer -Suffix $Suffix 26 | 27 | if (!$imageProperties) { 28 | Write-Error "Failed to capture $VMName, exiting" 29 | Exit 1 30 | } 31 | 32 | # Deploy the VHD 33 | .\Deploy-VHD.ps1 -VHDUri $imageProperties.Image -TargetStorageAccounts 'All' 34 | 35 | # Pend the change to the images file 36 | $images = .\Get-Images.ps1 -------------------------------------------------------------------------------- /management/nodes/Check-All-Images.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Check-All-Images.ps1 4 | .DESCRIPTION 5 | Check all the images in the store 6 | #> 7 | 8 | # Grab the image info 9 | $images = .\Get-Images.ps1 10 | 11 | foreach ($image in $images) { 12 | .\Check-Image.ps1 -ImageName $image.ImageName 13 | } -------------------------------------------------------------------------------- /management/nodes/Check-Image.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Check-Image.ps1 4 | .DESCRIPTION 5 | Checks that an image was correctly deployed 6 | .PARAMETER ImageName 7 | Image to check 8 | #> 9 | 10 | param ( 11 | [string]$ImageName 12 | ) 13 | 14 | # Right now we can really only check that the blob exists and is somewhere north of the expected amount 15 | 16 | # Ensure logged in 17 | $ctx = Get-AzureRmContext 18 | if (!$ctx) { 19 | Exit 20 | } 21 | 22 | Write-Output "Checking $ImageName" 23 | 24 | # Grab the image info 25 | $imageInfo = .\Get-Images.ps1 -ImageName $ImageName -Exact 26 | if (!$imageInfo) { 27 | Write-Error "Could not locate image $ImageName" 28 | Exit 29 | } 30 | 31 | # Check that the script is valid and available 32 | 33 | if (!(Test-Path $imageInfo.StartupScriptPath)) { 34 | Write-Error "Could find find startup script named $($imageInfo.StartupScriptPath). Please ensure a startup script is checked in" 35 | } 36 | 37 | # Walk all the storage accounts and ensure they all have the image 38 | # If the storage account is marked as 'All', read list of target storage accounts 39 | $targetAccounts = $imageInfo.StorageAccounts 40 | if ($targetAccounts -eq 'All') { 41 | $targetAccounts = Get-Content 'StorageAccounts.txt' | Select-String '^[^#]' | % { $_.ToString() } 42 | } 43 | else { 44 | Write-Error "Unexpected storage account name $targetAccounts. Semicolon separated list NYI" 45 | Exit 46 | } 47 | 48 | $firstSize = -1 49 | $firstStorageAccount = $null 50 | 51 | foreach ($targetAccount in $targetAccounts) { 52 | $targetContext = .\Get-Storage-Context.ps1 -StorageAccountName $targetAccount 53 | 54 | $targetVHDUri = .\Get-VHD-Location.ps1 -ImageName $ImageName -StorageAccountName $targetAccount 55 | 56 | # Look up the blob VHD 57 | $blobInfo = Get-AzureStorageBlob -Container $imageInfo.Container -Blob $imageInfo.BlobName -Context $targetContext -ErrorAction SilentlyContinue 58 | if (!$blobInfo) { 59 | Write-Error "Could not locate $ImageName at VHD location $targetVHDUri" 60 | continue 61 | } 62 | 63 | if ($blobInfo.Length -eq 0) { 64 | Write-Error "Size of VHD in $targetAccount is 0" 65 | Exit 66 | } 67 | 68 | if (!$firstStorageAccount) { 69 | $firstSize = $blobInfo.Length 70 | $firstStorageAccount = $targetAccount 71 | } 72 | elseif($firstSize -ne $blobInfo.Length) { 73 | Write-Error "Size of VHD in $targetAccount ($($blobInfo.Length)) doesn't match $firstStorageAccount ($firstSize)" 74 | } 75 | 76 | Write-Output "$ImageName in $targetAccount is correct." 77 | } 78 | 79 | Write-Output "All locations verified" -------------------------------------------------------------------------------- /management/nodes/Clean-Deployments.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Clean-Deployments 4 | .DESCRIPTION 5 | Cleans deployments from resource groups so we don't go over azure limits 6 | .PARAMETER ImageBaseName 7 | Base name for the final image name. 8 | .PARAMETER Run forever 9 | .PARAMETER ResourceGroupName 10 | Resource group to clean 11 | #> 12 | 13 | param ( 14 | [Parameter(Mandatory=$true)] 15 | [string]$ResourceGroupName, 16 | [switch]$RunForever = $false, 17 | [switch]$DryRun = $false 18 | ) 19 | 20 | do { 21 | $deployments = Get-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName 22 | # Delete from oldest first 23 | $deployments = $deployments | Sort-Object Timestamp 24 | foreach ($deployment in $deployments) { 25 | if ($DryRun) { 26 | Write-Output "Would delete $($deployment.DeploymentName) from $ResourceGroupName" 27 | } else { 28 | Write-Output "Deleting $($deployment.DeploymentName) from $ResourceGroupName" 29 | Remove-AzureRmResourceGroupDeployment -Name $deployment.DeploymentName -ResourceGroupName $ResourceGroupName 30 | } 31 | } 32 | } 33 | while($RunForever) -------------------------------------------------------------------------------- /management/nodes/Deploy-Image.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Deploy-Image.ps1 4 | .DESCRIPTION 5 | Deploys an image in the storage to a set of targets specified in the image file 6 | #> 7 | 8 | param ( 9 | [string]$ImageName, 10 | [string]$SourceStorageAccount = 'dotnetciuservmstorage3' 11 | ) 12 | 13 | $imageInfo = .\Get-Images.ps1 -ImageName $ImageName 14 | 15 | if (!$imageInfo) { 16 | Write-Error "Couldn't find image $ImageName" 17 | } 18 | 19 | $vhdUri = .\Get-VHD-Location.ps1 -ImageName $ImageName -StorageAccountName $SourceStorageAccount 20 | 21 | if (!$vhdUri) { 22 | Write-Error "Couldn't get VHD URI" 23 | } 24 | 25 | .\Deploy-VHD.ps1 -VHDUri $vhdUri -TargetStorageAccounts $imageInfo.StorageAccounts 26 | -------------------------------------------------------------------------------- /management/nodes/Get-Available-Resource-Groups.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Get-Available-Resource-Groups.ps1 4 | .DESCRIPTION 5 | Gets the available resource groups 6 | #> 7 | 8 | Get-Content 'ResourceGroups.txt' | Select-String '^[^#]' | % { $_.ToString() } -------------------------------------------------------------------------------- /management/nodes/Get-Connection-Info.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Get-ConnectionInfo.ps1 4 | .DESCRIPTION 5 | Retrieves connection info for a VM 6 | .PARAMETER VMName 7 | VM to get connection info for 8 | .PARAMETER ResourceGroupName 9 | Resource group containing the VM 10 | #> 11 | 12 | param ( 13 | [string]$VMName = $null, 14 | [string]$ResourceGroupName = $null 15 | ) 16 | 17 | # Ensure logged in 18 | $ctx = Get-AzureRmContext 19 | if (!$ctx) { 20 | Exit 21 | } 22 | 23 | # If the RG was not specified, read from the list 24 | $resourceGroups = @($ResourceGroupName) 25 | if (!$ResourceGroupName) { 26 | $resourceGroups = Get-Content 'ResourceGroups.txt' | Select-String '^[^#]' 27 | } 28 | 29 | # Walk each RG and look up the VM 30 | 31 | foreach ($resourceGroup in $resourceGroups) { 32 | $existingVM = Get-AzureRmVM -ResourceGroupName $resourceGroup -Name $VMName -ErrorAction SilentlyContinue 33 | 34 | if ($existingVM) { 35 | Write-Verbose "Found $VMName in $resourceGroup" 36 | # Grab the NIC info 37 | $nicId = $existingVM.NetworkProfile.NetworkInterfaces[0].Id 38 | # Parse out the name of the NIC 39 | $nicName = $nicId.Substring($nicId.LastIndexOf('/') + 1) 40 | # Grab the NIC info 41 | Write-Verbose "Looking up NIC $nicName" 42 | $nicInfo = Get-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $resourceGroup -ErrorAction SilentlyContinue 43 | 44 | if (!$nicInfo) { 45 | Write-Error "Could not find information on NIC $nicName in $resourceGroup" 46 | } 47 | 48 | # Get the IP configurations 49 | $pipId = $nicInfo.IpConfigurations[0].PublicIpAddress.Id 50 | 51 | if (!$pipId) { 52 | Write-Error "NIC $nicName doesn't have a public IP address" 53 | } 54 | 55 | # Parse out the name of the PIP 56 | $pipName = $pipId.Substring($pipId.LastIndexOf('/') + 1) 57 | 58 | # Look up the PIP 59 | $pipInfo = Get-AzureRmPublicIpAddress -Name $pipName -ResourceGroupName $resourceGroup -ErrorAction SilentlyContinue 60 | 61 | if (!$pipInfo) { 62 | Write-Error "Could not find information on PIP $pipName in $resourceGroup" 63 | } 64 | 65 | # Check and see whether there are DNS settings. Use those if possible 66 | $fqdn = $pipInfo.DnsSettings.Fqdn 67 | $targetAddressOrIP = $null 68 | if ($fqdn) { 69 | $targetAddressOrIP = $fqdn 70 | } 71 | else { 72 | # Grab the raw public IP address 73 | $targetAddressOrIP = $pipInfo.IpAddress 74 | } 75 | 76 | Write-Output "Connection Strings" 77 | Write-Output "------------------" 78 | if ($existingVM.OSProfile.linuxConfiguration) { 79 | # Write out various strings 80 | Write-Output "PuTTY SSH: putty $targetAddressOrIP" 81 | Write-Output "SSH: ssh $targetAddressOrIP" 82 | } 83 | else { 84 | Write-Output "RDP: mstsc /v:$targetAddressOrIP" 85 | } 86 | Exit 87 | } 88 | } 89 | 90 | Write-Error "Could not find any VM named $VMName" -------------------------------------------------------------------------------- /management/nodes/Get-Images.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Get-Images.ps1 4 | .DESCRIPTION 5 | Retrieves a set of available .NET CI images and their descriptions from Azure 6 | .PARAMETER ImageName 7 | Optional name of the image to match against. Substring match. 8 | .PARAMETER ImageCsv 9 | Csv file of image infoc 10 | #> 11 | 12 | param ( 13 | [string]$ImageName = $null, 14 | [switch]$Exact = $false, 15 | [string]$ImageCsv = 'Images.csv' 16 | ) 17 | 18 | # Read Images.csv 19 | 20 | if ($ImageName) { 21 | if ($Exact) { 22 | Get-Content $ImageCsv | Select-String '^[^#]' | ConvertFrom-Csv | Where-Object { $_.ImageName -eq $ImageName } 23 | } 24 | else { 25 | Get-Content $ImageCsv | Select-String '^[^#]' | ConvertFrom-Csv | Where-Object { $_.ImageName -match $ImageName } 26 | } 27 | } else { 28 | Get-Content $ImageCsv | Select-String '^[^#]' | ConvertFrom-Csv 29 | } -------------------------------------------------------------------------------- /management/nodes/Get-Resource-Group.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Get-Resource-Group.ps1 4 | .DESCRIPTION 5 | Get the resource group for a storage account 6 | .PARAMETER StorageAccountName 7 | Storage account to find 8 | #> 9 | 10 | param ( 11 | [string]$StorageAccountName 12 | ) 13 | 14 | # Ensure logged in 15 | $ctx = Get-AzureRmContext 16 | if (!$ctx) { 17 | Exit 18 | } 19 | 20 | $resourceGroups = .\Get-Available-Resource-Groups.ps1 21 | 22 | # Walk each RG and look up the storage key 23 | foreach ($resourceGroup in $resourceGroups) { 24 | $storageAccount = Get-AzureRmStorageAccount $StorageAccountName -ResourceGroupName $resourceGroup -ErrorAction SilentlyContinue 25 | if ($storageAccount) { 26 | Write-Output $resourceGroup 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /management/nodes/Get-Storage-Context.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Get-Storage-Context.ps1 4 | .DESCRIPTION 5 | Get a storage context for a storage account 6 | .PARAMETER StorageAccountName 7 | Storage account to get a context for 8 | #> 9 | 10 | param ( 11 | [string]$StorageAccountName 12 | ) 13 | 14 | # Ensure logged in 15 | $ctx = Get-AzureRmContext 16 | if (!$ctx) { 17 | Exit 18 | } 19 | 20 | $resourceGroupName = .\Get-Resource-Group.ps1 -StorageAccountName $StorageAccountName 21 | 22 | $storageAccountKeys = Get-AzureRmStorageAccountKey $StorageAccountName -ResourceGroupName $resourceGroupName -ErrorAction SilentlyContinue 23 | if (!$storageAccountKeys) { 24 | Write-Error "Could not get storage account key for $StorageAccountName" 25 | Exit 26 | } 27 | 28 | # Workaround for different powershell versions 29 | if ($storageAccountKeys[0]) { 30 | $storageAccountKey = $storageAccountKeys[0].Value 31 | } 32 | else { 33 | $storageAccountKey = $storageAccountKeys.Key1 34 | } 35 | 36 | New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $storageAccountKey 37 | -------------------------------------------------------------------------------- /management/nodes/Get-Target-Storage-Accounts.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Check-Image.ps1 4 | .DESCRIPTION 5 | Checks that an image was correctly deployed 6 | .PARAMETER ImageName 7 | Image to check 8 | #> 9 | 10 | param ( 11 | [string]$ImageName 12 | ) 13 | -------------------------------------------------------------------------------- /management/nodes/Get-VHD-Location.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Get-VHDLocation 4 | .DESCRIPTION 5 | Given an image name, retrieve a VHD URI, either with or without a storage account 6 | .PARAMETER ImageName 7 | Image name to create a VM with 8 | .PARAMETER StorageAccountName 9 | Name of the VM to create. 10 | #> 11 | 12 | param ( 13 | [string]$ImageName = $(Read-Host -prompt "VM image to lookup"), 14 | [string]$StorageAccountName = 'dotnetciuservmstorage3', 15 | [string]$ImageCsv = 'Images.csv' 16 | ) 17 | 18 | # Read Images.csv 19 | $image = .\Get-Images.ps1 -ImageName $ImageName -Exact 20 | 21 | if (!$image) { 22 | Write-Error "Could not find $ImageName" 23 | } 24 | 25 | Write-Output "https://$StorageAccountName.blob.core.windows.net/$($image.Container)/$($image.BlobName)" -------------------------------------------------------------------------------- /management/nodes/Parse-VHD-Uri.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Parse-VHD-Uri.ps1 4 | .DESCRIPTION 5 | Parse out a VHD URI 6 | .PARAMETER VHDUri 7 | #> 8 | 9 | param ( 10 | [string]$VHDUri 11 | ) 12 | 13 | # Parse out the source URI info 14 | $uriInfo = [regex]::Match($VHDUri, "^https?://(?.*).blob.core.windows.net/(?.*?)/((?.*)/)?(?.*\.vhd)$") 15 | 16 | if (!$uriInfo.Success) { 17 | Write-Error "Could not parse $VHDUri" 18 | Exit 19 | } 20 | 21 | $uriProperties = @{'StorageAccount'=$uriInfo.Groups["storageaccountname"].Value; 22 | 'ContainerName'=$uriInfo.Groups["containername"].Value; 23 | 'Blob'=$uriInfo.Groups["blobname"].Value; 24 | 'VirtualPath'=$uriInfo.Groups["virtualpath"].Value} 25 | 26 | Write-Output $uriProperties -------------------------------------------------------------------------------- /management/nodes/ResourceGroups.txt: -------------------------------------------------------------------------------- 1 | # Contains a list of resource groups that could potentially contain VMs 2 | dotnet-ci1-vms 3 | dotnet-ci2-vms 4 | dotnet-ci3-vms 5 | dotnet-ci4-vms 6 | dotnet-vsts-vms 7 | dotnet-ci-user-vms 8 | dotnet-ci1-vms-west 9 | dotnet-ci2-vms-west 10 | dotnet-ci3-vms-west 11 | dotnet-ci4-vms-west 12 | dotnet-vsts-vms-west 13 | dotnet-ci-user-vms-west -------------------------------------------------------------------------------- /management/nodes/StorageAccounts.txt: -------------------------------------------------------------------------------- 1 | # List of storage accounts that we target for images 2 | # so they can be used by various services 3 | dotnetci1vmstorage2 4 | dotnetci2vmstorage2 5 | dotnetci3vmstorage2 6 | dotnetci4vmstorage2 7 | dotnetvstsvmstorage2 8 | dotnetciuservmstorage2 9 | dotnetci1vmstorage3 10 | dotnetci2vmstorage3 11 | dotnetci3vmstorage3 12 | dotnetci4vmstorage3 13 | dotnetciuservmstorage3 -------------------------------------------------------------------------------- /management/nodes/reboot/osx/osx_python.sh: -------------------------------------------------------------------------------- 1 | URL=$(cat /Volumes/SHARE/reboot_url.txt) 2 | curl -s -o $HOME/Desktop/reboot.py -O $URL 3 | /usr/local/bin/python3 $HOME/Desktop/reboot.py $1 $2 -------------------------------------------------------------------------------- /management/nodes/reboot/tripleboot-reboot-script.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | import sys 4 | import fileinput 5 | import subprocess 6 | import platform 7 | import shutil 8 | import re 9 | print("windows=1\nubuntu=2\nOSX=4") 10 | 11 | WINDOWS = "1" 12 | UBUNTU = "2" 13 | OSX = "4" 14 | 15 | def find_file(filename,path): 16 | for root,dirs,files in os.walk(path): 17 | for name in files: 18 | if name==filename: 19 | return os.path.abspath(os.path.join(root, name)) 20 | 21 | def replace_text(file,tempfile,destext): 22 | f = open( file,'r+' ) 23 | open(tempfile, 'w').write(re.sub(".*?default_selection\\s+\\d", destext, f.read())) 24 | f.close() 25 | 26 | if(len(sys.argv) != 3): 27 | print("Invalid usage. Expected 2 arguments: FROM_OS_LABEL, TO_OS_LABEL") 28 | exit() 29 | 30 | if(sys.argv[1] == WINDOWS): 31 | print ("Call Windows tasks") 32 | subprocess.call("mountvol z: /s") 33 | result=find_file('refind.conf','z:\\') 34 | if os.path.exists("z:\\refind_backup.conf"): 35 | print ("The copy of orignal refind.conf already exists") 36 | else: 37 | shutil.copy(result,"z:\\refind_backup.conf") 38 | print (result) 39 | tempfile="d:\\refind1.conf" 40 | replace_text(result,tempfile,"default_selection " + sys.argv[2]) 41 | shutil.copy(tempfile,result); 42 | print ("The next boot OS has changed. Shutting down.") 43 | subprocess.call("shutdown /t 5 /r") 44 | 45 | elif(sys.argv[1] == UBUNTU): 46 | print ("Call Linux tasks") 47 | os.system("sudo -bash") 48 | result=find_file('refind.conf','/boot/efi') 49 | print (result) 50 | 51 | # backup refind.conf 52 | if os.path.exists("/boot/efi/refind_backup.conf"): 53 | print ("The copy of orignal refind.conf already exists") 54 | else: 55 | shutil.copy(result,"/boot/efi/refind_backup.conf") 56 | 57 | #replace the boot text 58 | tempfile = "/boot/efi/refind_temp.conf" 59 | #tempfile = "/home/peptest/Desktop/refind_temp.conf" 60 | replace_text(result,tempfile,"default_selection " + sys.argv[2]) 61 | shutil.copy(tempfile,result) 62 | print ("The next boot OS has changed. Shutting down.") 63 | os.system("sudo reboot") 64 | 65 | elif(sys.argv[1] == OSX): 66 | #mount EFI partition 67 | print ("Call IOS tasks") 68 | if os.path.exists("/Volumes/efi"): 69 | print ("Folder /Volumes/efi already exists") 70 | else: 71 | os.mkdir("/Volumes/efi") 72 | os.system("sudo mount -t msdos /dev/disk0s1 /Volumes/efi") 73 | 74 | #find refind.conf 75 | result=find_file('refind.conf','/Volumes/efi') 76 | print (result) 77 | 78 | # backup refind.conf 79 | if os.path.exists("/Volumes/efi/refind_backup.conf"): 80 | print ("The copy of orignal refind.conf already exists") 81 | else: 82 | shutil.copy(result,"/Volumes/efi/refind_backup.conf") 83 | 84 | #replace the boot text 85 | tempfile = "/Volumes/efi/refind_temp.conf" 86 | #tempfile = "/Users/peptest/Desktop/refind_temp.conf" 87 | replace_text(result,tempfile,"default_selection " + sys.argv[2]) 88 | shutil.copy(tempfile,result) 89 | print ("The next boot OS has changed. Shutting down.") 90 | os.system("sudo reboot") 91 | 92 | else: 93 | print ("No operating system found with label " + sys.argv[1]) 94 | -------------------------------------------------------------------------------- /management/nodes/reboot/ubuntu/mount_cmd.sh: -------------------------------------------------------------------------------- 1 | sudo lsblk -o UUID,MOUNTPOINT,FSTYPE | grep SHARE | xargs printf "# shared drive\nUUID=%s %s %s defaults 0 2\n" | sudo tee -a /etc/fstab -------------------------------------------------------------------------------- /management/nodes/reboot/ubuntu/ubuntu_python.sh: -------------------------------------------------------------------------------- 1 | URL=$(cat /media/$(logname)/SHARE/reboot_url.txt) 2 | curl -s -o $HOME/Desktop/reboot.py -O $URL 3 | python3 $HOME/Desktop/reboot.py $1 $2 -------------------------------------------------------------------------------- /management/nodes/reboot/windows/create_reboot_task.bat: -------------------------------------------------------------------------------- 1 | powershell -command "& { [IO.File]::ReadAllText('create_reboot_task.xml') -f (Get-Date -UFormat '%%Y-%%m-%%dT%%T.0000000'), [Environment]::MachineName, [Environment]::UserName, '%userprofile%\Desktop\reboot\reboot_script.bat', '%userprofile%\Desktop\reboot' | Out-File create_reboot_task_output.xml }" 2 | schtasks /Create /XML create_reboot_task_output.xml /TN RebootScript -------------------------------------------------------------------------------- /management/nodes/reboot/windows/create_reboot_task.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/dotnet-ci/e224e39175d54af9f3cde9773d886502890d1be5/management/nodes/reboot/windows/create_reboot_task.xml -------------------------------------------------------------------------------- /management/nodes/reboot/windows/launch_jenkins_task.bat: -------------------------------------------------------------------------------- 1 | powershell -command "& { [IO.File]::ReadAllText('launch_jenkins_task.xml') -f (Get-Date -UFormat '%%Y-%%m-%%dT%%T.0000000'), [Environment]::MachineName, [Environment]::UserName, '%userprofile%\Desktop\slave-agent.jnlp' | Out-File launch_jenkins_task_output.xml }" 2 | schtasks /Create /XML launch_jenkins_task_output.xml /TN LaunchJenkins -------------------------------------------------------------------------------- /management/nodes/reboot/windows/launch_jenkins_task.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/dotnet-ci/e224e39175d54af9f3cde9773d886502890d1be5/management/nodes/reboot/windows/launch_jenkins_task.xml -------------------------------------------------------------------------------- /management/nodes/reboot/windows/reboot_script.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd /d %userprofile%\Desktop\reboot\ 3 | FOR /f "tokens=1,2" %%i in (arguments.txt) do py.exe -3 reboot.py %%i %%j > "result.txt" -------------------------------------------------------------------------------- /management/nodes/reboot/windows/win10_python.bat: -------------------------------------------------------------------------------- 1 | SET /p URL= %userprofile%\Desktop\reboot\arguments.txt 4 | schtasks /run /tn "RebootScript" -------------------------------------------------------------------------------- /management/nodes/startupScripts/centos71-20160609-1-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | 4 | chmod -R 777 /mnt/resource/ -------------------------------------------------------------------------------- /management/nodes/startupScripts/centos71-20160929.sh: -------------------------------------------------------------------------------- 1 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 2 | rm /etc/sudoers.d/zzz-dotnet-bot 3 | 4 | # Disable huge pages temporarily. 5 | bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' 6 | 7 | # Occasionally the resource disk doesn't exist 8 | if [ ! -d "/mnt/resource/" ]; then 9 | exit 1 10 | fi 11 | 12 | mkdir /mnt/resource/j 13 | chmod -R 777 /mnt/resource/j -------------------------------------------------------------------------------- /management/nodes/startupScripts/centos71-20170216-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | 4 | chmod -R 777 /mnt/resource/ -------------------------------------------------------------------------------- /management/nodes/startupScripts/centos71-20170216.sh: -------------------------------------------------------------------------------- 1 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 2 | rm /etc/sudoers.d/zzz-dotnet-bot 3 | 4 | # Disable huge pages temporarily. 5 | bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' 6 | 7 | # Occasionally the resource disk doesn't exist 8 | if [ ! -d "/mnt/resource/" ]; then 9 | exit 1 10 | fi 11 | 12 | mkdir /mnt/resource/j 13 | chmod -R 777 /mnt/resource/j -------------------------------------------------------------------------------- /management/nodes/startupScripts/deb82-20160323-outer.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/dotnet-ci/e224e39175d54af9f3cde9773d886502890d1be5/management/nodes/startupScripts/deb82-20160323-outer.sh -------------------------------------------------------------------------------- /management/nodes/startupScripts/deb82-20160323.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | sudo chmod 777 /mnt/resource -------------------------------------------------------------------------------- /management/nodes/startupScripts/deb84-20160623-outer.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/resource 3 | 4 | # Make dotnet-bot sudo not prompt for passwords 5 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 6 | 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/deb84-20160623.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/resource 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/deb84-20170214-outer.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/resource 3 | 4 | # Make dotnet-bot sudo not prompt for passwords 5 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 6 | 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/deb84-20170214.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/resource 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/fedora23-20160622-outer.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/resource 3 | 4 | # Make dotnet-bot sudo not prompt for passwords 5 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 6 | 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/fedora23-20160622.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt/resource folder writeable 2 | chmod -R 777 /mnt/resource/ 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/fedora24-20161024-outer.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/resource 3 | 4 | # Make dotnet-bot sudo not prompt for passwords 5 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 6 | 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/fedora24-20161024.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt/resource folder writeable 2 | chmod -R 777 /mnt/resource/ 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/fedora24-20170420-outer.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/resource 3 | 4 | # Make dotnet-bot sudo not prompt for passwords 5 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 6 | 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/fedora24-20170420.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt/resource folder writeable 2 | chmod -R 777 /mnt/resource/ 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/freebsd-20161025.sh: -------------------------------------------------------------------------------- 1 | # Create the workspace and make it writeable 2 | chmod 777 /mnt/resource/ -------------------------------------------------------------------------------- /management/nodes/startupScripts/rhel72-20160211.sh: -------------------------------------------------------------------------------- 1 | # Create the workspace and make it writeable 2 | chmod 777 /mnt/resource/ 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/rhel72-20160412-1-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | 4 | # Create the workspace and make it writeable 5 | chmod 777 /mnt/resource/ 6 | 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/rhel72-20170525.sh: -------------------------------------------------------------------------------- 1 | # Create the workspace and make it writeable 2 | chmod 777 /mnt/resource/ 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/suse132-20160315-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | # Make the /mnt folder writeable 4 | chmod 777 /mnt/resource/ 5 | # Restart docker since now the mnt drive is writeable 6 | service docker restart 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/suse132-20160315.sh: -------------------------------------------------------------------------------- 1 | chmod -R 777 /mnt/resource/ 2 | 3 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 4 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/suse421-20160920-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | chmod -R 777 /mnt/resource/ 4 | 5 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 6 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/suse421-20160920.sh: -------------------------------------------------------------------------------- 1 | chmod 777 /mnt/resource/ 2 | 3 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 4 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/suse421-20170216-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | chmod -R 777 /mnt/resource/ 4 | 5 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 6 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/suse421-20170216.sh: -------------------------------------------------------------------------------- 1 | chmod 777 /mnt/resource/ 2 | 3 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 4 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20160206-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | # Make the /mnt folder writeable 4 | chmod -R 777 /mnt/ 5 | # Restart docker since now the mnt drive is writeable 6 | service docker restart -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20160211-1-internal.sh: -------------------------------------------------------------------------------- 1 | # Restart docker since now the mnt drive is writeable 2 | service docker restart 3 | docker run hello-world 4 | if [ $? -ne 0 ] 5 | then 6 | exit 1 7 | fi 8 | 9 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 10 | rm /etc/sudoers.d/zzz-dotnet-bot 11 | 12 | # Test mkdir 13 | mkdir /mnt/j 14 | # Make the /mnt folder writeable 15 | chmod 777 /mnt/j 16 | 17 | if [ $? -ne 0 ]; then 18 | echo "Could not mkdir, VM not ready for use" 19 | fi -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20160211-1.sh: -------------------------------------------------------------------------------- 1 | # Restart docker since now the mnt drive is writeable 2 | service docker restart 3 | docker run hello-world 4 | if [ $? -ne 0 ] 5 | then 6 | exit 1 7 | fi 8 | 9 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 10 | rm /etc/sudoers.d/zzz-dotnet-bot 11 | 12 | # Disable huge pages temporarily. 13 | bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' 14 | 15 | # Test mkdir 16 | mkdir /mnt/j 17 | # Make the /mnt folder writeable 18 | chmod 777 /mnt/j 19 | 20 | if [ $? -ne 0 ]; then 21 | echo "Could not mkdir, VM not ready for use" 22 | fi -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20160818.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/ 3 | # Restart docker since now the mnt drive is writeable 4 | service docker restart 5 | 6 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 7 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20161019.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/ 3 | # Restart docker since now the mnt drive is writeable 4 | service docker restart 5 | 6 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 7 | rm /etc/sudoers.d/zzz-dotnet-bot 8 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20161020.sh: -------------------------------------------------------------------------------- 1 | # Restart docker since now the mnt drive is writeable 2 | service docker restart 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot 6 | 7 | # Test mkdir 8 | mkdir /mnt/j 9 | # Make the /mnt folder writeable 10 | chmod 777 /mnt/j 11 | 12 | if [ $? -ne 0 ]; then 13 | echo "Could not mkdir, VM not ready for use" 14 | fi -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20170109.sh: -------------------------------------------------------------------------------- 1 | # Restart docker since now the mnt drive is writeable 2 | service docker restart 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot 6 | 7 | # Disable huge pages temporarily. 8 | bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' 9 | 10 | # Test mkdir 11 | mkdir /mnt/j 12 | # Make the /mnt folder writeable 13 | chmod 777 /mnt/j 14 | 15 | if [ $? -ne 0 ]; then 16 | echo "Could not mkdir, VM not ready for use" 17 | fi -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20170118.sh: -------------------------------------------------------------------------------- 1 | # Restart docker since now the mnt drive is writeable 2 | service docker restart 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot 6 | 7 | # Disable huge pages temporarily. 8 | bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' 9 | 10 | # Test mkdir 11 | mkdir /mnt/j 12 | # Make the /mnt folder writeable 13 | chmod 777 /mnt/j 14 | 15 | if [ $? -ne 0 ]; then 16 | echo "Could not mkdir, VM not ready for use" 17 | fi -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20170728-outer.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/ 3 | 4 | # Restart docker since now the mnt drive is writeable, then ensure that the daemon is running properly with a hello-world 5 | service docker restart 6 | docker run hello-world 7 | if [ $? -ne 0 ] 8 | then 9 | exit 1 10 | fi -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20170728.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/ 3 | 4 | # Restart docker since now the mnt drive is writeable, then ensure that the daemon is running properly with a hello-world 5 | service docker restart 6 | docker run hello-world 7 | if [ $? -ne 0 ] 8 | then 9 | exit 1 10 | fi -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20170821.sh: -------------------------------------------------------------------------------- 1 | # Check that Azure's temporary storage was mounted correctly 2 | if ! mountpoint -q "/mnt"; then 3 | echo "Azure's tmp storage not mounted" 4 | exit 1 5 | fi 6 | 7 | # Make the /mnt folder writeable 8 | chmod 777 /mnt/ 9 | 10 | # Restart docker since now the mnt drive is writeable, then ensure that the daemon is running properly with a hello-world 11 | service docker restart 12 | docker run hello-world 13 | if [ $? -ne 0 ] 14 | then 15 | exit 1 16 | fi 17 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20170925.sh: -------------------------------------------------------------------------------- 1 | # Check that Azure's temporary storage was mounted correctly 2 | if ! mountpoint -q "/mnt"; then 3 | echo "Azure's tmp storage not mounted" 4 | exit 1 5 | fi 6 | 7 | # Make the /mnt folder writeable 8 | chmod 777 /mnt/ 9 | 10 | # Restart docker since now the mnt drive is writeable, then ensure that the daemon is running properly with a hello-world 11 | service docker restart 12 | docker run hello-world 13 | if [ $? -ne 0 ] 14 | then 15 | exit 1 16 | fi 17 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1404-20180321.sh: -------------------------------------------------------------------------------- 1 | # Check that Azure's temporary storage was mounted correctly 2 | if ! mountpoint -q "/mnt"; then 3 | echo "Azure's tmp storage not mounted" 4 | exit 1 5 | fi 6 | 7 | # Make the /mnt folder writeable 8 | chmod 777 /mnt/ 9 | 10 | # Restart docker since now the mnt drive is writeable, then ensure that the daemon is running properly with a hello-world 11 | service docker restart 12 | docker run hello-world 13 | if [ $? -ne 0 ] 14 | then 15 | exit 1 16 | fi 17 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1510-20160307-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | # Make the /mnt folder writeable 4 | chmod 777 /mnt/ 5 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 6 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1510-20160307.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod 777 /mnt/ 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1604-20160510-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | 4 | # Make the /mnt folder writeable 5 | chmod -R 777 /mnt/ 6 | 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1604-20160510.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod -R 777 /mnt/ 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1604-20160803.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | sudo chmod 777 /mnt/ 3 | # Restart docker since now the mnt drive is writeable 4 | sudo service docker restart 5 | 6 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 7 | sudo rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1604-20170109.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | sudo chmod 777 /mnt/ 3 | # Restart docker since now the mnt drive is writeable 4 | sudo service docker restart 5 | 6 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 7 | sudo rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1604-20170216-outer-outer.sh: -------------------------------------------------------------------------------- 1 | # Make dotnet-bot sudo not prompt for passwords 2 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 3 | 4 | # Make the /mnt folder writeable 5 | chmod -R 777 /mnt/ 6 | 7 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 8 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1604-20170216-outer.sh: -------------------------------------------------------------------------------- 1 | # Make the /mnt folder writeable 2 | chmod -R 777 /mnt/ 3 | 4 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 5 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1610-20160927-outer.sh: -------------------------------------------------------------------------------- 1 | # Test mkdir 2 | mkdir /mnt/j 3 | # Make the /mnt folder writeable 4 | chmod 777 /mnt/j 5 | 6 | # Make dotnet-bot sudo not prompt for passwords 7 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 8 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 9 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1610-20160927.sh: -------------------------------------------------------------------------------- 1 | # Test mkdir 2 | mkdir /mnt/j 3 | # Make the /mnt folder writeable 4 | chmod 777 /mnt/j 5 | 6 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 7 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1610-20170216-outer.sh: -------------------------------------------------------------------------------- 1 | # Test mkdir 2 | mkdir /mnt/j 3 | # Make the /mnt folder writeable 4 | chmod 777 /mnt/j 5 | 6 | # Make dotnet-bot sudo not prompt for passwords 7 | bash -c 'echo "dotnet-bot ALL=NOPASSWD: ALL" | (EDITOR="tee -a" visudo)' 8 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 9 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/ubuntu1610-20170216.sh: -------------------------------------------------------------------------------- 1 | # Test mkdir 2 | mkdir /mnt/j 3 | # Make the /mnt folder writeable 4 | chmod 777 /mnt/j 5 | 6 | # Remove the file that allows dotnet-bot paswordless, nointeractive sudoing (since we are done sudoing now). 7 | rm /etc/sudoers.d/zzz-dotnet-bot -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2012-20160506.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 52 | Restart-Computer -Force -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2012-20160707-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 52 | Restart-Computer -Force -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2012-20160707.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 52 | Restart-Computer -Force -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2012-20160824-elevated.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $false 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 52 | Restart-Computer -Force -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20160825.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Cleanup the machine gitconfig file: https://github.com/dotnet/dotnet-ci/issues/358 45 | Remove-Item -Path "C:\Program Files\Git\mingw64\etc\gitconfig" 46 | New-Item -Path "C:\Program Files\Git\mingw64\etc\gitconfig" -Type File 47 | 48 | # Enable LUA 49 | if ($enableLUA) 50 | { 51 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 52 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 53 | } 54 | 55 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 56 | Restart-Computer -Force -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170113-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170113.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170128-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170128.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170207-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170207.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170213-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170213.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170214-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170214.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170302.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Cleanup the machine gitconfig file: https://github.com/dotnet/dotnet-ci/issues/358 45 | Remove-Item -Path "C:\Program Files\Git\mingw64\etc\gitconfig" 46 | New-Item -Path "C:\Program Files\Git\mingw64\etc\gitconfig" -Type File 47 | 48 | # Enable LUA 49 | if ($enableLUA) 50 | { 51 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 52 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 53 | } 54 | 55 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 56 | Restart-Computer -Force -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170307-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170307.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170427-1-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170427-1.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170427-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170427.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170510-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170510.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170531.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170613.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170712.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170717.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170731.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170802.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170814.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-20170919.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-base-internal.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /management/nodes/startupScripts/win2016-base.ps1: -------------------------------------------------------------------------------- 1 | Set-ExecutionPolicy Unrestricted 2 | 3 | $machineSetupLog = 'C:\setup.log' 4 | $jenkinsServerUrl = $args[0] 5 | echo ('Jenkins Server URL: {0}' -f $jenkinsServerUrl) | Out-File -Append $machineSetupLog 6 | $vmName = $args[1] 7 | echo ('Virtual Machine Name: {0}' -f $vmName) | Out-File -Append $machineSetupLog 8 | $secret = $args[2] 9 | echo ('Secret: {0}' -f $secret) | Out-File -Append $machineSetupLog 10 | 11 | $winLogonRegistryPath = 'hklm:\software\microsoft\windows nt\currentversion\winlogon\' 12 | $jenkinsDirectory = 'C:\Jenkins' 13 | $jenkinsLaunchCmd = Join-Path -Path $jenkinsDirectory -ChildPath 'launch.cmd' 14 | $jenkinsStartupScript = Join-Path -Path $jenkinsDirectory -ChildPath 'jenkins-windows-startup.ps1' 15 | $jenkinsLogFile = Join-Path -Path $jenkinsDirectory -ChildPath 'log.txt' 16 | # The image needs to have LUA off to run properly. If you want the VM to have administrative permissions for 17 | # everything set $enableLUA to $false. 18 | $enableLUA = $true 19 | $enableLUARegistryPath = 'hklm:\software\Microsoft\Windows\CurrentVersion\policies\system\' 20 | 21 | # Create the Jenkins directory 22 | if (!(Test-Path -Path $jenkinsDirectory)) 23 | { 24 | Write-Output ('Creating Jenkins Directory: {0}' -f $jenkinsDirectory) | Out-File -Append $machineSetupLog 25 | New-Item -Path $jenkinsDirectory -Force -ItemType Directory 26 | } 27 | 28 | # Set the time zone 29 | tzutil /s "Pacific Standard Time" 30 | 31 | # Generate the launch cmd 32 | $content = 'powershell.exe {0} -URL {1} -VMName {2} -Secret {3} > {4}' -f $jenkinsStartupScript, $jenkinsServerUrl, $vmName, $secret, $jenkinsLogFile 33 | Write-Output ('Creating Jenkins Launcher. File: {0}; Content: {1}' -f $jenkinsLaunchCmd, $content) | Out-File -Append $machineSetupLog 34 | $content | Out-File -FilePath $jenkinsLaunchCmd -Encoding ascii -Force 35 | 36 | # Set up auto-login 37 | Write-Output 'Registering dotnet-bot for auto-login' | Out-File -Append $machineSetupLog 38 | 39 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultUserName' -Value 'dotnet-bot' -PropertyType string -Force 40 | New-ItemProperty -Path $winLogonRegistryPath -Name 'DefaultPassword' -Value '' -PropertyType string -Force 41 | 42 | New-ItemProperty -Path $winLogonRegistryPath -Name 'AutoAdminLogon' -Value '1' -PropertyType string -Force 43 | 44 | # Enable LUA 45 | if ($enableLUA) 46 | { 47 | Write-Output 'Enabling UAC/LUA' | Out-File -Append $machineSetupLog 48 | New-ItemProperty -Path $enableLUARegistryPath -Name 'EnableLUA' -Value 1 -PropertyType DWORD -Force 49 | } 50 | 51 | # Register the logon task if it doesn't exist 52 | $scheduledTaskExists = Get-ScheduledTask | Where-Object { $_.TaskName -like "Jenkins-Startup" } 53 | 54 | if (!$scheduledTaskExists) { 55 | Write-Output 'Registering the launch script to run on user login' | Out-File -Append $machineSetupLog 56 | $scheduledTaskTrigger = New-ScheduledTaskTrigger -AtLogOn -User dotnet-bot 57 | $scheduledTaskAction = New-ScheduledTaskAction -Execute C:\Jenkins\launch.cmd 58 | $scheduledTaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 4 -ExecutionTimeLimit ([TimeSpan]::Zero) 59 | $scheduledTaskPrincipal = New-ScheduledTaskPrincipal -UserId dotnet-bot -LogonType Interactive 60 | Register-ScheduledTask Jenkins-Startup -Action $scheduledTaskAction -Trigger $scheduledTaskTrigger -Principal $scheduledTaskPrincipal -Settings $scheduledTaskSettings 61 | } 62 | 63 | Write-Output 'Rebooting' | Out-File -Append $machineSetupLog 64 | Restart-Computer -Force 65 | -------------------------------------------------------------------------------- /poke/pokefile: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /scripts/disable_jobs_in_folder.groovy: -------------------------------------------------------------------------------- 1 | import hudson.model.* 2 | import jenkins.model.* 3 | 4 | // Grab the parameters 5 | 6 | def resolver = build.buildVariableResolver 7 | String FolderName = resolver.resolve("FolderName").toString() 8 | boolean DisableSubFolderItems = resolver.resolve("DisableSubFolderItems").toString().toBoolean() 9 | boolean DryRunOnly = resolver.resolve("DryRunOnly").toBoolean() 10 | assert FolderName != '' && FolderName != '/' 11 | if (!FolderName.startsWith('/')) { 12 | FolderName = "/" + FolderName 13 | } 14 | 15 | print ('Disabling jobs in ' + FolderName) 16 | if (DisableSubFolderItems) { 17 | print (' and any folders under that') 18 | } 19 | if (DryRunOnly) { 20 | print (' (dry run)') 21 | } 22 | 23 | // Disable a folder for deletion later. 24 | disableFolder(FolderName, DryRunOnly, DisableSubFolderItems, Jenkins.instance.items) 25 | 26 | def disableFolder(String folderName, boolean dryRunOnly, boolean disableSubfolders, items, String currentFolderName = '') { 27 | for (item in items) { 28 | if (item.class.canonicalName != 'com.cloudbees.hudson.plugins.folder.Folder') { 29 | if (folderName == currentFolderName || (disableSubfolders && currentFolderName.startsWith(folderName))) { 30 | if (!dryRunOnly) { 31 | println ("Disabling ${currentFolderName}/" + item.name); 32 | item.disabled=true 33 | item.save() 34 | } 35 | else { 36 | println ("Would Disable ${currentFolderName}/" + item.name); 37 | } 38 | } 39 | } else { 40 | if (folderName != currentFolderName || disableSubfolders) { 41 | disableFolder(folderName, dryRunOnly, disableSubfolders, ((com.cloudbees.hudson.plugins.folder.Folder) item).getItems(), currentFolderName + "/" + item.name) 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /scripts/disable_swap_space_monitor.groovy: -------------------------------------------------------------------------------- 1 | import hudson.model.ComputerSet 2 | 3 | for (int i = 0; i < ComputerSet.monitors.size(); i++) { 4 | if (ComputerSet.monitors.getAt(i) instanceof hudson.node_monitors.SwapSpaceMonitor) { 5 | ComputerSet.monitors.remove((ComputerSet.monitors.getAt(i))) 6 | } 7 | } -------------------------------------------------------------------------------- /scripts/queue-failed-generators.groovy: -------------------------------------------------------------------------------- 1 | hudson.model.Hudson.instance.getView('Generators').items.each() { 2 | if (it instanceof FreeStyleProject) { 3 | def timeSince = groovy.time.TimeCategory.minus( new Date(), it.getLastBuild().getTime() ) 4 | if (it.getLastBuild().getResult() != Result.SUCCESS) { 5 | println it.fullDisplayName 6 | it.scheduleBuild2(60) 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /scripts/queue-generators-older.groovy: -------------------------------------------------------------------------------- 1 | hudson.model.Hudson.instance.getView('Generators').items.each() { 2 | if (it instanceof FreeStyleProject) { 3 | def timeSince = groovy.time.TimeCategory.minus( new Date(), it.getLastBuild().getTime() ) 4 | if (timeSince.getDays() > 5) { 5 | println it.fullDisplayName + " " + timeSince 6 | it.scheduleBuild2(60) 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /scripts/remove_offline_nodes.groovy: -------------------------------------------------------------------------------- 1 | // Removes offline nodes from AzureVMAgents that weren't taken offline for user reasons 2 | 3 | import jenkins.model.Jenkins 4 | import com.microsoft.azure.vmagent.AzureVMAgent 5 | import com.microsoft.helix.helixagents.HelixAgent 6 | 7 | def nodes = Jenkins.instance.getNodes() 8 | 9 | nodes.each { node -> 10 | if (node instanceof AzureVMAgent || node instanceof HelixAgent) { 11 | if (node.getComputer() != null) { 12 | if (node.getComputer().isTemporarilyOffline()) { 13 | def cause = node.getComputer().getOfflineCause() 14 | if (!(cause instanceof hudson.slaves.OfflineCause.UserCause) && 15 | (!(node instanceof HelixAgent) || !(cause instanceof hudson.slaves.OfflineCause.SimpleOfflineCause))) { 16 | println "Removing " + node.getComputer().getName() + " " 17 | Jenkins.instance.removeNode(node) 18 | } 19 | } 20 | } 21 | } 22 | } 23 | 24 | return true 25 | -------------------------------------------------------------------------------- /scripts/show-running-prs.groovy: -------------------------------------------------------------------------------- 1 | def busyExecutors = Jenkins.instance.computers 2 | .collect { 3 | c -> c.executors.findAll { it.isBusy() } 4 | } 5 | .flatten() // reminder: transforms list(list(executor)) into list(executor) 6 | 7 | println "Currently executing PRs" 8 | busyExecutors.each { e -> 9 | def build = e.executable 10 | def causes = e .executable.getCauses() 11 | causes.each { cause -> 12 | if (cause instanceof org.jenkinsci.plugins.ghprb.GhprbCause) { 13 | println cause.getUrl() 14 | } 15 | } 16 | } 17 | 18 | return "After restart, please go to each PR and comment 'test this please'" -------------------------------------------------------------------------------- /scripts/take_offline.groovy: -------------------------------------------------------------------------------- 1 | import hudson.model.* 2 | import hudson.slaves.OfflineCause; 3 | 4 | def node = Hudson.getInstance().getNode($NODE_NAME)) 5 | println("Attempting to take this machine offline: " + node.name); 6 | def computer = node.getComputer() 7 | 8 | if (node.getComputer().isOffline()) { 9 | println(" Offline, skipping"); 10 | } 11 | else { 12 | computer.setTemporarilyOffline(true); 13 | } -------------------------------------------------------------------------------- /src/jobs/generation/ArchivalSettings.groovy: -------------------------------------------------------------------------------- 1 | package jobs.generation; 2 | 3 | class ArchivalSettings { 4 | String[] filesToArchive = null; 5 | String[] filesToExclude = null; 6 | boolean failIfNothingArchived = true 7 | private String[] archiveStatus = defaultSuccessArchiveStatus 8 | private static String[] defaultSuccessArchiveStatus = ['SUCCESS', 'SUCCESS'] 9 | private static String[] defaultFailingArchiveStatus = ['ABORTED', 'FAILURE'] 10 | private static String[] defaultAlwaysArchiveStatus = ['FAILURE', 'SUCCESS'] 11 | 12 | void setArchiveOnFailure() { 13 | archiveStatus = defaultFailingArchiveStatus 14 | } 15 | 16 | void setArchiveOnSuccess() { 17 | archiveStatus = defaultSuccessArchiveStatus 18 | } 19 | 20 | void setAlwaysArchive() { 21 | archiveStatus = defaultAlwaysArchiveStatus 22 | } 23 | 24 | String[] getArchiveStatusRange() { 25 | return archiveStatus 26 | } 27 | 28 | void addFiles(String archiveBlob) { 29 | if (filesToArchive == null) { 30 | filesToArchive = [archiveBlob] 31 | } else { 32 | filesToArchive += archiveBlob 33 | } 34 | } 35 | 36 | void excludeFiles(String archiveBlob) { 37 | if (filesToExclude == null) { 38 | filesToExclude = [archiveBlob] 39 | } else { 40 | filesToExclude += archiveBlob 41 | } 42 | } 43 | 44 | boolean setFailIfNothingArchived() { 45 | failIfNothingArchived = true 46 | } 47 | 48 | boolean setDoNotFailIfNothingArchived() { 49 | failIfNothingArchived = false 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/jobs/generation/GenerationSettings.groovy: -------------------------------------------------------------------------------- 1 | package jobs.generation; 2 | 3 | import hudson.EnvVars; 4 | import hudson.model.Executor; 5 | 6 | class GenerationSettings { 7 | // Retrieves a setting value through the environment of the current build 8 | private static String getSetting(String setting) { 9 | EnvVars env = Executor.currentExecutor().getCurrentExecutable().getEnvironment() 10 | return env.get(setting, null) 11 | } 12 | 13 | private static boolean getSettingAsBoolean(String setting, boolean defaultValue) { 14 | String value = getSetting(setting) 15 | if (value == null) { 16 | return defaultValue 17 | } 18 | return Boolean.parseBoolean(value) 19 | } 20 | 21 | public static boolean isTestGeneration() { 22 | return getSettingAsBoolean("IsTestGeneration", false) 23 | } 24 | 25 | public static String getServerName() { 26 | return getSetting("ServerName") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/jobs/generation/PostGen.groovy: -------------------------------------------------------------------------------- 1 | // This file is invoked after the repo generator file is run 2 | // This file can be used to run post steps, like creating job reports or help jobs 3 | 4 | println("Running PostGen") -------------------------------------------------------------------------------- /src/jobs/generation/PreGen.groovy: -------------------------------------------------------------------------------- 1 | // This file is invoked before the repo generator file is run. 2 | // Within the same DSL step, the groovy files will see the same object model. 3 | // So code in this file can affect the code in the netci.groovy. For instance, 4 | // this file could set a global indicating this is a pr test generation, which could 5 | // be used to to alter any number of options (for instance, altering triggers so that 6 | // generated jobs can be left un-disabled, but the default trigger options won't cause the 7 | // job to run for everyone. 8 | 9 | import jobs.generation.GenerationSettings 10 | 11 | println("Running PreGen") 12 | 13 | // Output the settings we're using 14 | if (GenerationSettings.isTestGeneration()) { 15 | println("Setting up for a generation test") 16 | } -------------------------------------------------------------------------------- /src/org/dotnet/ci/pipelines/scm/PipelineScm.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.ci.pipelines.scm; 2 | 3 | interface PipelineScm { 4 | String getBranch() 5 | void emitScmForPR(def job, String pipelineFile) 6 | void emitScmForNonPR(def job, String pipelineFile) 7 | String getScmType() 8 | } -------------------------------------------------------------------------------- /src/org/dotnet/ci/triggers/GenericTriggerBuilder.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.ci.triggers; 2 | 3 | import jobs.generation.JobReport 4 | import jobs.generation.Utilities 5 | 6 | // Covers a generic triggers in Jenkins 7 | // Periodic - Periodic triggers against a Git repo 8 | // Manual - No automatic trigger (or triggered manually) 9 | class GenericTriggerBuilder implements TriggerBuilder { 10 | public enum TriggerType { 11 | PERIODIC, 12 | MANUAL 13 | } 14 | 15 | // Periodic 16 | // Cron string representing the execution period 17 | private String _cronString 18 | // Always run regardless of the commit state 19 | private boolean _alwaysRun = false 20 | // Trigger TriggerType 21 | private TriggerType _triggerType 22 | 23 | // Returns true if the trigger is a PR (private or PR branch) SCM, vs. 'official' 24 | public boolean isPRTrigger() { 25 | return false 26 | } 27 | 28 | private GenericTriggerBuilder(TriggerType triggerType) { 29 | this._triggerType = triggerType 30 | } 31 | 32 | /* Constructs a new periodic trigger 33 | * 34 | * @param cronString Cron string to run the job on 35 | * @return New periodic trigger that runs on the specified interval 36 | */ 37 | def static GenericTriggerBuilder triggerPeriodically(String cronString) { 38 | def newTrigger = new GenericTriggerBuilder(TriggerType.PERIODIC) 39 | newTrigger._cronString = cronString 40 | return newTrigger 41 | } 42 | 43 | /* Constructs a new manual trigger. This effectivley means no trigger 44 | * 45 | * @return New manual trigger 46 | */ 47 | def static GenericTriggerBuilder triggerManually() { 48 | def newTrigger = new GenericTriggerBuilder(TriggerType.MANUAL) 49 | return newTrigger 50 | } 51 | 52 | // Forces the periodic trigger to run regardless of source change 53 | def alwaysRunPeriodicTrigger() { 54 | assert this._triggerType == TriggerType.PERIODIC 55 | this._alwaysRun = true 56 | } 57 | 58 | // Emits the trigger for the specific job 59 | // Parameters: 60 | // job - Job to emit trigger for 61 | void emitTrigger(def job) { 62 | assert (this._triggerType == TriggerType.PERIODIC) || (this._triggerType == TriggerType.MANUAL) 63 | 64 | if (this._triggerType == TriggerType.PERIODIC) { 65 | job.with { 66 | triggers { 67 | if (this._alwaysRun) { 68 | cron(this._cronString) 69 | } 70 | else { 71 | scm(this._cronString) 72 | } 73 | } 74 | } 75 | JobReport.Report.addCronTriggeredJob(job.name, this._cronString, this._alwaysRun) 76 | } 77 | else if (this._triggerType == TriggerType.MANUAL) { 78 | JobReport.Report.addManuallyTriggeredJob(job.name) 79 | } 80 | else { 81 | assert false : "Unknown trigger type" 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /src/org/dotnet/ci/triggers/TriggerBuilder.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.ci.triggers; 2 | 3 | interface TriggerBuilder { 4 | boolean isPRTrigger() 5 | void emitTrigger(def job) 6 | } -------------------------------------------------------------------------------- /src/org/dotnet/ci/util/Constants.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.ci.util; 2 | 3 | public class Constants { 4 | public static int DEFAULT_PIPELINE_TIMEOUT = 120 5 | } -------------------------------------------------------------------------------- /src/org/dotnet/helix/HelixEvent.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.helix; 2 | 3 | import java.util.UUID 4 | 5 | class HelixEvent { 6 | private static String s_connectionString 7 | private static String s_stagingConnectionString 8 | 9 | static void Initialize(String eventHubConnectionString, String eventHubStagingConnectionString = null) { 10 | s_connectionString = eventHubConnectionString 11 | s_stagingConnectionString = eventHubStagingConnectionString 12 | } 13 | 14 | public static IHelixEventSender CreateSender(String correlationId, String workItemId) { 15 | if(IsNullOrWhitespace(s_connectionString)) { 16 | return s_nullSender 17 | } 18 | return new HelixEventSender(correlationId, workItemId, s_connectionString, s_stagingConnectionString) 19 | } 20 | 21 | public static IHelixEventSender CreateSender(String correlationId) { 22 | if(IsNullOrWhitespace(s_connectionString)) { 23 | return s_nullSender 24 | } 25 | return new HelixEventSender(correlationId, UUID.randomUUID().toString(), s_connectionString, s_stagingConnectionString) 26 | } 27 | 28 | public static IHelixEventSender CreateSender() { 29 | if(IsNullOrWhitespace(s_connectionString)) { 30 | return s_nullSender 31 | } 32 | return new HelixEventSender(UUID.randomUUID().toString(), UUID.randomUUID().toString(), s_connectionString, s_stagingConnectionString) 33 | } 34 | 35 | private static Boolean IsNullOrWhitespace(String testString) { 36 | return testString == null || testString.isEmpty() || testString.trim().isEmpty() 37 | } 38 | 39 | private static IHelixEventSender s_nullSender = new NoopSender() 40 | } -------------------------------------------------------------------------------- /src/org/dotnet/helix/HelixEventData.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.helix; 2 | 3 | import groovy.json.* 4 | 5 | class HelixEventData { 6 | String type 7 | String correlationId 8 | String workItemId 9 | Map data 10 | 11 | public String toJson() { 12 | def eventDataMap = [:] 13 | eventDataMap.Type = type 14 | eventDataMap.CorrelationId = correlationId 15 | eventDataMap.WorkItemId = workItemId 16 | 17 | data.each { prop, val -> 18 | if(prop != "Properties") { 19 | eventDataMap.put(prop, val) 20 | } 21 | } 22 | if(data.Properties != null) { 23 | eventDataMap.put("Properties", new JsonBuilder(data.Properties).toString()) 24 | } 25 | 26 | return new JsonBuilder(eventDataMap).toString() 27 | } 28 | } -------------------------------------------------------------------------------- /src/org/dotnet/helix/HelixEventSender.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.helix; 2 | 3 | // ToDo: probably need to remove this and add the jars to jenkins as we don't want external dependencies 4 | @Grab(group='com.microsoft.azure', module='azure-eventhubs', version='0.14.5') 5 | 6 | import com.microsoft.azure.eventhubs.* 7 | 8 | class HelixEventSender implements IHelixEventSender { 9 | String correlationId 10 | String workItemId 11 | 12 | final EventHubClient _sender 13 | final EventHubClient _stagingSender 14 | 15 | public HelixEventSender(String correlationId, 16 | String workItemId, 17 | String eventHubConnectionString, 18 | String stagingEventHubConnectionString = null) { 19 | this.correlationId = correlationId 20 | this.workItemId = workItemId 21 | _sender = EventHubClient.createFromConnectionString(eventHubConnectionString).get() 22 | if(stagingEventHubConnectionString != null) { 23 | _stagingSender = EventHubClient.createFromConnectionString(stagingEventHubConnectionString).get() 24 | } 25 | } 26 | 27 | String Send(HelixEventData data) { 28 | if (data == null) throw new Exception("HelixEventData is null") 29 | 30 | data.correlationId = correlationId 31 | data.workItemId = workItemId 32 | 33 | def jsonString = '' 34 | try { 35 | jsonString = data.toJson() 36 | EventData eventData = new EventData(data.toJson().getBytes()) 37 | if(_sender != null) { 38 | _sender.send(eventData) 39 | } 40 | if(_stagingSender != null) { 41 | _stagingSender.send(eventData) 42 | } 43 | } 44 | catch(Exception e) { 45 | println e.getMessage() 46 | println e.getLocationText() 47 | throw e 48 | } 49 | return jsonString 50 | } 51 | 52 | IHelixEventSender GetForRelatedWorkItem(String workItemId) { 53 | return new HelixEventSender(correlationId, workItemId, _sender, _stagingSender) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/org/dotnet/helix/HelixTraceListener.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.helix; 2 | 3 | class HelixTraceListener { 4 | // @groovy.beans.ListenerList 5 | List listeners 6 | IHelixEventSender EventSender 7 | } -------------------------------------------------------------------------------- /src/org/dotnet/helix/IHelixEventSender.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.helix; 2 | 3 | interface IHelixEventSender { 4 | String Send(HelixEventData data) 5 | IHelixEventSender GetForRelatedWorkItem(String workItemId) 6 | String correlationId 7 | } -------------------------------------------------------------------------------- /src/org/dotnet/helix/NoopSender.groovy: -------------------------------------------------------------------------------- 1 | package org.dotnet.helix; 2 | 3 | import java.util.UUID 4 | 5 | class NoopSender implements IHelixEventSender { 6 | public final String correlationId 7 | 8 | public String Send(HelixEventData data) {return ''} 9 | 10 | public IHelixEventSender GetForRelatedWorkItem(String workItemId) {return this} 11 | 12 | public NoopSender() { 13 | this.correlationId = new UUID(0L, 0L) 14 | } 15 | } -------------------------------------------------------------------------------- /tests/dsl/pipeline_manual_trigger.groovy: -------------------------------------------------------------------------------- 1 | import org.dotnet.ci.pipelines.Pipeline 2 | 3 | // Tests creation of a pipeline that triggers on pushes with non-string parameter types 4 | def newPipeline = Pipeline.createPipeline(this, 'simple_periodic.groovy') 5 | 6 | newPipeline.triggerPipelineManually(['Hello':false]) -------------------------------------------------------------------------------- /tests/dsl/pipeline_periodic_trigger.groovy: -------------------------------------------------------------------------------- 1 | import org.dotnet.ci.pipelines.Pipeline 2 | 3 | // Tests creation of a pipeline that triggers on pushes with non-string parameter types 4 | def newPipeline = Pipeline.createPipeline(this, 'simple_periodic.groovy') 5 | 6 | newPipeline.triggerPipelinePeriodically('@hourly', ['Hello':false]) -------------------------------------------------------------------------------- /tests/dsl/pipeline_pr_trigger.groovy: -------------------------------------------------------------------------------- 1 | import org.dotnet.ci.pipelines.Pipeline 2 | 3 | // Tests creation of a pipeline that triggers on pushes with non-string parameter types 4 | def newPipeline = Pipeline.createPipeline(this, 'simple_pr.groovy') 5 | 6 | try { 7 | newPipeline.triggerPipelineOnEveryPR('CI Test', ['Hello':false]) 8 | } 9 | catch (AssertionError e) { 10 | assert e.getMessage().indexOf("VSTS PR pipelines are NYI") != -1 : "Expected 'VSTS PR pipelines are NYI'" 11 | } -------------------------------------------------------------------------------- /tests/dsl/pipeline_simple_push_trigger.groovy: -------------------------------------------------------------------------------- 1 | import org.dotnet.ci.pipelines.Pipeline 2 | 3 | // Tests creation of a pipeline that triggers on pushes 4 | def newPipeline = Pipeline.createPipeline(this, 'simple_push.groovy') 5 | 6 | // No parameters 7 | newPipeline.triggerPipelineOnPush() 8 | 9 | // Parameters 10 | newPipeline.triggerPipelineOnPush(['Hello':'World']) -------------------------------------------------------------------------------- /tests/dsl/simple_job_check_out_to_subdir.groovy: -------------------------------------------------------------------------------- 1 | // Import the utility functionality. 2 | 3 | import jobs.generation.Utilities; 4 | 5 | def project = QualifiedRepoName 6 | def branch = BranchName 7 | 8 | [true, false].each { isPR -> 9 | def newJob = job(Utilities.getFullJobName(project, "checkouttosubdir", isPR)) { 10 | steps { 11 | batchFile("echo Hello World") 12 | } 13 | } 14 | 15 | Utilities.setMachineAffinity(newJob, "Windows_NT", 'latest-or-auto') 16 | // Leave */ on this, should be replaced by refs/heads/ 17 | Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}") 18 | 19 | // After calling standardJobSetup, modify the job so it checks out to a subdir 20 | Utilities.addScmInSubDirectory(newJob, project, isPR, 'mysubdir') 21 | } -------------------------------------------------------------------------------- /tests/dsl/simple_traditional_job.groovy: -------------------------------------------------------------------------------- 1 | // Import the utility functionality. 2 | 3 | import jobs.generation.Utilities; 4 | 5 | def project = QualifiedRepoName 6 | def branch = BranchName 7 | 8 | [true, false].each { isPR -> 9 | def newJob = job(Utilities.getFullJobName(project, "FooBarTest", isPR)) { 10 | steps { 11 | batchFile("echo Hello World") 12 | } 13 | } 14 | 15 | Utilities.setMachineAffinity(newJob, "Windows_NT", 'latest-or-auto') 16 | Utilities.standardJobSetup(newJob, project, isPR, "refs/heads/${branch}") 17 | } -------------------------------------------------------------------------------- /tests/dsl/test_repro_job.groovy: -------------------------------------------------------------------------------- 1 | import jobs.generation.Utilities; 2 | 3 | def project = QualifiedRepoName 4 | def branch = BranchName 5 | 6 | // Generate a job to test ReproTool Plugin 7 | def reproJob = job(Utilities.getFullJobName(project, 'simple_repro', false)) { 8 | steps { 9 | batchFile('fail.cmd') 10 | } 11 | label('test-vm') 12 | } 13 | Utilities.standardJobSetup(reproJob, project, false, "refs/heads/${branch}") 14 | -------------------------------------------------------------------------------- /tests/dsl/traditional_job_with_paren_in_name.groovy: -------------------------------------------------------------------------------- 1 | // Import the utility functionality. 2 | 3 | import jobs.generation.Utilities; 4 | 5 | def project = QualifiedRepoName 6 | def branch = BranchName 7 | 8 | [true, false].each { isPR -> 9 | def jobName = Utilities.getFullJobName(project, "FooBarTest (Name - Config=0)", isPR) 10 | def newJob = job(jobName) { 11 | steps { 12 | batchFile("echo Hello World") 13 | } 14 | } 15 | 16 | Utilities.setMachineAffinity(newJob, "Windows_NT", 'latest-or-auto') 17 | Utilities.standardJobSetup(newJob, project, isPR, "refs/heads/${branch}") 18 | Utilities.addGithubPRTrigger(newJob, jobName) 19 | } -------------------------------------------------------------------------------- /tests/dsl/utilities_tests.groovy: -------------------------------------------------------------------------------- 1 | // Utilities tests 2 | // Places here because there is some issue (related to https://issues.jenkins-ci.org/browse/JENKINS-42730) which causes odd issues when 3 | // things are imported from vars as well as a dynamically loaded library 4 | 5 | import jobs.generation.Utilities 6 | 7 | // With collection == devdiv, we add "DefaultColleciton" like in most servers 8 | assert Utilities.calculateVSTSGitURL('devdiv', 'foo/bar') == 'https://devdiv.visualstudio.com/DefaultCollection/foo/_git/bar' : "Incorrect url for devdiv collection git URL" 9 | 10 | // With collection == devdiv, we add "DefaultColleciton" like in most servers 11 | assert Utilities.calculateVSTSGitURL('other', 'foo/bar') == 'https://other.visualstudio.com/foo/_git/bar' : "Incorrect url for non-devdiv collection git URL" 12 | 13 | // With collection == devdiv, we add "DefaultColleciton" like in most servers 14 | assert Utilities.calculateGitHubURL('foo/bar') == 'https://github.com/foo/bar' : "Incorrect url for github URL" -------------------------------------------------------------------------------- /tests/pipeline/tests.groovy: -------------------------------------------------------------------------------- 1 | import org.dotnet.ci.pipelines.Pipeline 2 | import jobs.generation.Utilities 3 | 4 | // This file is pretty barebones. It basically just sets up a pipeline which then calls the tests. 5 | // This is opposed to setting up all the tests here, which is a little more difficult to square between PR and non-PR scenarios, 6 | // as well as for verification purposes. 7 | def testingPipeline = Pipeline.createPipeline(this, 'tests/pipeline/pipeline-tests.groovy') 8 | 9 | // Trigger this pipeline on pushes and PRs. 10 | // TODO: VSTS PRs 11 | if (VersionControlLocation != 'VSTS') { 12 | testingPipeline.triggerPipelineOnEveryPR("CI Tests (${ServerName})") 13 | } 14 | testingPipeline.triggerPipelineOnPush() 15 | 16 | // Make the call to generate the help job 17 | Utilities.createHelperJob(this, QualifiedRepoName, BranchName, 18 | "Welcome to the ${QualifiedRepoName} Repository", // This is prepended to the help message 19 | "Have a nice day!") // This is appended to the help message. You might put known issues here. -------------------------------------------------------------------------------- /vars/addSummaryLink.groovy: -------------------------------------------------------------------------------- 1 | // Given a header and text, add them to the status page 2 | // as a list 3 | 4 | def call (String header, Map urls, boolean isError = false) { 5 | def newSummary = manager.createSummary("terminal.gif") 6 | newSummary.appendText("${header}
    ", false) 7 | if (urls.size() > 0) { 8 | for ( item in urls ) { 9 | if(!isError) { 10 | newSummary.appendText("
  • "+item.key+"
  • ", false) 11 | } 12 | else { 13 | newSummary.appendText("
  • "+item.key+"
  • ", false, false, false, "red") 14 | } 15 | 16 | } 17 | } 18 | newSummary.appendText("
", false) 19 | } -------------------------------------------------------------------------------- /vars/archiveLogs.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Archive the auto-archived log folder 3 | */ 4 | def call() { 5 | String logFolder = getLogFolder() 6 | echo "Archiving logs in ${logFolder}/**" 7 | archiveArtifacts allowEmptyArchive: true, artifacts: "${logFolder}/**" 8 | } -------------------------------------------------------------------------------- /vars/checkoutRepo.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Checkout the source indicated in the scm section of the pipeline. 3 | * Includes automatic retry. The normal retry {} is problematic at least in some pipeline versions 4 | */ 5 | def call() { 6 | retry (10) { 7 | timeout(15) { 8 | checkout scm 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /vars/createSender.groovy: -------------------------------------------------------------------------------- 1 | import org.dotnet.helix.* 2 | def call(Map senderMap) { 3 | return call(senderMap.correlationId, senderMap.workItemId, senderMap.credentialsIdentifier) 4 | } 5 | def call(String credentialsIdentifier) { 6 | return call(null, null, credentialsIdentifier) 7 | } 8 | def call(String correlationId, String credentialsIdentifier) { 9 | return call(correlationId, null, credentialsIdentifier) 10 | } 11 | 12 | /* Create a helix event sender which is used to send events to the endpoint specified in the 13 | * credentialsIdentifier 14 | */ 15 | def call(String correlationId, String workItemId, String credentialsIdentifier) { 16 | withCredentials([string(credentialsId: credentialsIdentifier, variable: 'helixEndpoint')]) { 17 | HelixEvent.Initialize(env.helixEndpoint) 18 | if(correlationId != null) { 19 | if(workItemId != null) { 20 | return HelixEvent.CreateSender(correlationId, workItemId) 21 | } 22 | else { 23 | return HelixEvent.CreateSender(correlationId) 24 | } 25 | } 26 | else { 27 | return HelixEvent.CreateSender() 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /vars/createSenderMap.groovy: -------------------------------------------------------------------------------- 1 | /* Creates a "sender" Map object, which is a dictionary with these values 2 | * correlationId: value 3 | * workItemId: value 4 | * credentialsIdentifier: value 5 | * Generates new correlation and workItem id's if they are not specified' 6 | */ 7 | def call(String credentialsIdentifier, String correlationId = null, String workItemId = null ) { 8 | if(correlationId == null) { 9 | correlationId = generateRandomUUID() 10 | } 11 | if(workItemId == null) { 12 | workItemId = generateRandomUUID() 13 | } 14 | return Collections.synchronizedMap([correlationId: correlationId, 15 | workItemId: workItemId, 16 | credentialsIdentifier: credentialsIdentifier]) 17 | } -------------------------------------------------------------------------------- /vars/generateRandomUUID.groovy: -------------------------------------------------------------------------------- 1 | import java.util.UUID 2 | 3 | /* Return a random UUID string 4 | */ 5 | def call() { 6 | return UUID.randomUUID().toString() 7 | } 8 | -------------------------------------------------------------------------------- /vars/getBranch.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the branch that the commit is associated with. 3 | * Because it's very difficult to tell branch, this just pulls the BranchName parameter. 4 | */ 5 | def call() { 6 | return env["BranchName"] 7 | } -------------------------------------------------------------------------------- /vars/getBuildNumber.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves formatted official build number. 3 | * Depends on the Version Number Plugin (https://wiki.jenkins.io/display/JENKINS/Version+Number+Plugin) 4 | * to provide these variable values 5 | */ 6 | def call() { 7 | // The VersionNumber method takes a format string, and returns a conforming build number 8 | def versionNumber = VersionNumber('${BUILD_YEAR}${BUILD_MONTH, XX}${BUILD_DAY, XX}-${BUILDS_TODAY, XX}') 9 | assert versionNumber != null : "Version number is not a valid format, is the 'Version Number Plugin' installed?" 10 | return versionNumber 11 | } -------------------------------------------------------------------------------- /vars/getCommit.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the commit that the run should be associated with. 3 | * This is an interesting concept which requires some thought. 4 | * Becuase we can sync multiple repos, this command is sometimes dependent 5 | * on what directory we are in. For a PR, it retrieves the pr commit, regardless of directory. 6 | * If not in a PR, retrieves the commit of the current directory. In almost all cases this 7 | * will return the commit that a user would expect. In cases where multiple repos are cloned, 8 | * then this would return the PR commit instead of the current directory. In those cases, using 9 | * getCommitForDir and getCommitForPR can disambiguate. 10 | * @return Commit for this pipeline invocation. 11 | */ 12 | def call() { 13 | if (isPR()) { 14 | return getCommitForPR() 15 | } 16 | else { 17 | return getCommitForDir() 18 | } 19 | } -------------------------------------------------------------------------------- /vars/getCommitForDir.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the commit checked out in a specific directory. 3 | * Must be called under a workspace. Uses git to determine the checked out 4 | * commit. 5 | * @return The commit checked out in a specific directory, fails the step otherwise. 6 | */ 7 | def call() { 8 | def output 9 | if (isUnix()) { 10 | // Prefix with @ to avoid the command in the output 11 | output = sh script: 'git rev-parse HEAD', returnStdout: true 12 | 13 | } 14 | else { 15 | // Prefix with @ to avoid the command in the output 16 | output = bat script: '@git rev-parse HEAD', returnStdout: true 17 | } 18 | 19 | // Trim the output 20 | return output.trim() 21 | } -------------------------------------------------------------------------------- /vars/getCommitForPR.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the commit checked out in a PR. 3 | * If not a PR, then asserts. 4 | * @return ghprbActualCommit if a PR if GitHub (VSTS NYI) 5 | */ 6 | def call() { 7 | assert isPR() : "Not a PR" 8 | def versionControlLocation = getVersionControlLocation() 9 | if (versionControlLocation == "GitHub") { 10 | def commitSha = env["ghprbActualCommit"] 11 | assert !isNullOrEmpty(commitSha) : "Could not find commit sha" 12 | return commitSha 13 | } else if (versionControlLocation == "VSTS") { 14 | assert false : "NYI VSTS PR commit" 15 | } else { 16 | assert false : "Unknown version control location" 17 | } 18 | } -------------------------------------------------------------------------------- /vars/getEncodedUrl.groovy: -------------------------------------------------------------------------------- 1 | import hudson.Util 2 | 3 | /** 4 | * Retrieves an encoded URL element for Mission Control/Helix 5 | * While Jenkins's Util.rawEncode(...) works, it does not use the 6 | * same format for escape sequences as Angular. % vs. ~. So this simply 7 | * uses the Jenkins one and changes the % to ~. 8 | * @return Encoded url element. 9 | */ 10 | def call(String inputUrl) { 11 | String output = Util.rawEncode(inputUrl) 12 | return output.replaceAll("%", "~") 13 | } -------------------------------------------------------------------------------- /vars/getHelixSource.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Constructs the HelixSource submission parameter given the current environment. 3 | * @return Helix source 4 | */ 5 | def call() { 6 | def projectName = getRepo() 7 | def orgName = getOrganization() 8 | def branch = getBranch() 9 | if (isPR()) { 10 | return "pr/jenkins/${orgName}/${projectName}/${branch}/" 11 | } 12 | else { 13 | return "automated/jenkins/${orgName}/${projectName}/origin/${branch}/" 14 | } 15 | } -------------------------------------------------------------------------------- /vars/getLogFolder.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Get the folder where logs should be placed to be automatically archived. This is a relative path 3 | * not ending in / 4 | * @return Log folder. Creates if necessary 5 | */ 6 | def call() { 7 | return "netci-archived-logs" 8 | } -------------------------------------------------------------------------------- /vars/getOrganization.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the org associated the repository containing this pipeline. 3 | * This info is read from the input 'OrgOrProjectName' parameter. If this is not 4 | * specified, then asserts. 5 | * @return Org/VSTS project associated with this pipeline. 6 | */ 7 | def call() { 8 | def githubOrgName = env["OrgOrProjectName"] 9 | assert !isNullOrEmpty(githubOrgName) : "Could not find OrgOrProjectName parameter" 10 | return githubOrgName 11 | } -------------------------------------------------------------------------------- /vars/getPRNumber.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the number of the PR. 3 | * @return ghprbPullId if a PR (GitHub). VSTS NYI 4 | */ 5 | def call() { 6 | assert isPR() : "Not a PR" 7 | def versionControlLocation = getVersionControlLocation() 8 | if (versionControlLocation == "GitHub") { 9 | def pullId = env["ghprbPullId"] 10 | assert !isNullOrEmpty(pullId) : "Could not find pull id" 11 | return pullId 12 | } else if (versionControlLocation == "VSTS") { 13 | assert false : "NYI VSTS PR" 14 | } else { 15 | assert false : "Unknown version control location" 16 | } 17 | } -------------------------------------------------------------------------------- /vars/getRepo.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the project associated with this pipeline. 3 | * This info is read from the input 'RepoName' parameter. If this is not 4 | * specified, then asserts. 5 | * @return Repository associated with this run. 6 | */ 7 | def call() { 8 | def repoName = env["RepoName"] 9 | assert !isNullOrEmpty(repoName) : "Could not find RepoName parameter" 10 | return repoName 11 | } -------------------------------------------------------------------------------- /vars/getSenderMap.groovy: -------------------------------------------------------------------------------- 1 | import org.dotnet.helix.* 2 | 3 | def call(String credentialsIdentifier) { 4 | return call(null, null, credentialsIdentifier) 5 | } 6 | 7 | def call(String correlationId, String credentialsIdentifier) { 8 | return call(correlationId, null, credentialsIdentifier) 9 | } 10 | 11 | def call(String correlationId, String workItemId, String credentialsIdentifier) { 12 | withCredentials([string(credentialsId: credentialsIdentifier, variable: 'HelixEndpoint')]) { 13 | def sender = createSender(correlationId, workItemId, credentialsIdentifier) 14 | return [CorrelationId: sender.CorrelationId, 15 | WorkItemId: sender.WorkItemId, 16 | CredentialsIdentifier: credentialsIdentifier] 17 | } 18 | } -------------------------------------------------------------------------------- /vars/getUser.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the user that this job was associated with. 3 | * This is: 4 | * dotnet-bot (default) if triggered by a user. 5 | * logged in github user - If triggered manually through the UI 6 | * pr originator (ghprbPullAuthorLogin) - If triggered via the PR builder (even if triggered by another user) 7 | * @return User associated with this run. 8 | */ 9 | def call() { 10 | def isPRJob = isPR(); 11 | if (isPRJob) { 12 | def ghPullUser = env["ghprbPullAuthorLogin"] 13 | assert !isNullOrEmpty(ghPullUser) : "Could not locate the pull author login." 14 | return ghPullUser 15 | } 16 | else { 17 | // Do some digging to determine how the job was launched. There are a couple easy possibilities: 18 | 19 | // user ID cause -> manually launched runs 20 | def userIdCause = currentBuild.rawBuild.getCause(hudson.model.Cause$UserIdCause) 21 | 22 | if (userIdCause != null) { 23 | return userIdCause.getUserId() 24 | } 25 | else { 26 | // Return dotnet-bot as the default 27 | return 'dotnet-bot' 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /vars/getUserEmail.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Retrieves the user email that this job was associated with. 3 | * This is: 4 | * dotnet-bot@microsoft.com (default) if triggered by a user. 5 | * logged in github user's email - If triggered manually through the UI 6 | * pr originator (ghprbPullAuthorEmail) - If triggered via the PR builder (even if triggered by another user) 7 | * pr originator's github username + @github.login - If triggered via the PR builder and email is not available 8 | * @return User associated with this run. 9 | */ 10 | def call() { 11 | def isPRJob = isPR(); 12 | if (isPRJob) { 13 | def versionControlLocation = getVersionControlLocation() 14 | if (versionControlLocation == "GitHub") { 15 | def ghPullUserEmail = env["ghprbPullAuthorEmail"] 16 | if (isNullOrEmpty(ghPullUserEmail)) { 17 | ghPullUserEmail = getUser() + "@github.login" 18 | } 19 | assert !isNullOrEmpty(ghPullUserEmail) : "Could not locate the pull author email." 20 | return ghPullUserEmail 21 | } else if (versionControlLocation == "VSTS") { 22 | assert false : "NYI VSTS PR" 23 | } else { 24 | assert false : "Unknown version control location" 25 | } 26 | } 27 | else { 28 | // Do some digging to determine how the job was launched. There are a couple easy possibilities: 29 | 30 | // user ID cause -> manually launched runs 31 | def userIdCause = currentBuild.rawBuild.getCause(hudson.model.Cause$UserIdCause) 32 | 33 | if (userIdCause != null) { 34 | def userId = userIdCause.getUserId() 35 | def userIdMailer = hudson.model.User.get(userId).getProperty(hudson.tasks.Mailer.class) 36 | def userIdEmail = "" 37 | if (isNullOrEmpty(userIdMailer)) { 38 | userIdEmail = userId + "@github.login" 39 | } 40 | else { 41 | userIdEmail = userIdMailer.getAddress() 42 | } 43 | return userIdEmail 44 | } 45 | else { 46 | // Return dotnet-bot as the default 47 | return 'dotnet-bot@microsoft.com' 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vars/getVersionControlLocation.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns what version control host this pipeline is running in 3 | * @return True if this was triggered as part of a PR, false otherwise. 4 | */ 5 | def call() { 6 | def vcLocation = env["VersionControlLocation"] 7 | assert !isNullOrEmpty(vcLocation) : "Version control location parameter not set (VersionControlLocation)" 8 | return vcLocation 9 | } -------------------------------------------------------------------------------- /vars/isNullOrEmpty.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns true if the string is null or empty 3 | * @param input String to check 4 | * @return User associated with this run. 5 | */ 6 | def call(String input) { 7 | return input == null || input == "" 8 | } -------------------------------------------------------------------------------- /vars/isPR.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Determines whether the pipeline was invoked as part of a PR or not. 3 | * @return True if this was triggered as part of a PR, false otherwise. 4 | */ 5 | def call() { 6 | def versionControlLocation = getVersionControlLocation() 7 | if (versionControlLocation == "GitHub") { 8 | def repository = env["ghprbGhRepository"] 9 | return (!isNullOrEmpty(repository)) 10 | } else if (versionControlLocation == "VSTS") { 11 | // PR is not supported at the moment, so just return false for now 12 | return false 13 | } else { 14 | assert false : "Unknown version control location" 15 | } 16 | } -------------------------------------------------------------------------------- /vars/loadPipeline.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Loads a pipeline from a file in the workspace. Effectively just 'load' but under a workspace. 3 | * @return New pipeline, which can be invoked. 4 | */ 5 | def call(String pipelineFile) { 6 | simpleNode('Windows_NT','latest') { 7 | checkout scm 8 | return load(pipelineFile) 9 | } 10 | } -------------------------------------------------------------------------------- /vars/makeLogFolder.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Make the log folder. 3 | */ 4 | def call() { 5 | String logFolder = getLogFolder() 6 | if (isUnix()) { 7 | sh "mkdir -p '${logFolder}'" 8 | } 9 | else { 10 | bat "if not exist \"${logFolder}\" mkdir \"${logFolder}\"" 11 | } 12 | } -------------------------------------------------------------------------------- /vars/sendEvent.groovy: -------------------------------------------------------------------------------- 1 | import org.dotnet.helix.* 2 | 3 | def call(String type, Map data, Map senderMap, Integer maxRetries = 3, Integer waitTimeInMilliseconds = 1000) { 4 | def sender = createSender(senderMap) 5 | def eventData = new HelixEventData() 6 | eventData.type = type 7 | eventData.data = data 8 | 9 | return Send(sender, eventData, 0, maxRetries, waitTimeInMilliseconds) 10 | } 11 | 12 | /** 13 | * Send event data with retry logic, if not succesful after 'maxRetries', ignore the failure and continue 14 | */ 15 | def Send(IHelixEventSender sender, HelixEventData eventData, Integer attempt, Integer maxRetries, Integer waitTimeInMilliseconds) { 16 | try { 17 | return sender.Send(eventData) 18 | } 19 | catch(Exception) { 20 | if(attempt < maxRetries) { 21 | println "Send event failed, will retry in ${waitTimeInMilliseconds} ms (retry ${attempt + 1} / ${maxRetries})" 22 | Thread.sleep(waitTimeInMilliseconds) 23 | return Send(data, attempt + 1, maxRetries) 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /vars/setPRStatus.groovy: -------------------------------------------------------------------------------- 1 | // Sets a commit status for a PR. Relies on the following: 2 | // pipeline must have been triggered by the GHPRB triggered 3 | // other parameters (auth, etc.) must be present in environment and valid 4 | // if they are not there, this step is skipped, commit status is echoed. 5 | // This file is a workaround to the inability seamlessly set this today. 6 | import org.kohsuke.github.GHCommitState; 7 | import org.kohsuke.github.GHRepository; 8 | import org.kohsuke.github.GitHub; 9 | import org.jenkinsci.plugins.ghprb.GhprbGitHubAuth; 10 | import org.jenkinsci.plugins.ghprb.GhprbTrigger; 11 | import org.kohsuke.github.GHCommitState; 12 | 13 | def call(String context, String state, String url, String subMessage = '') { 14 | // Validate the state 15 | assert (state == "PENDING" || state == "SUCCESS" || state == "FAILURE" || state == "ERROR") : "Valid states are PENDING, SUCCESS, FAILURE and ERROR, was ${state}" 16 | GHCommitState ghState = GHCommitState.valueOf(state) 17 | 18 | // Gather required parameters. If missing, echo to let the 19 | // owner know 20 | def credentialsId = env["ghprbCredentialsId"] 21 | if (isNullOrEmpty(credentialsId)) { 22 | echo "Could not find credentials ID (ghprbCredentialsId), ${context} (${subMessage}) is ${state}, see ${url}" 23 | return 24 | } 25 | 26 | // Grab the repository associated 27 | def repository = env["ghprbGhRepository"] 28 | if (isNullOrEmpty(repository)) { 29 | echo "Could not find repository name (ghprbGhRepository), ${context} (${subMessage}) is ${state}, see ${url}" 30 | return 31 | } 32 | // Find the commit commitSha 33 | def commitSha = env["ghprbActualCommit"] 34 | if (isNullOrEmpty(commitSha)) { 35 | echo "Could not find sha (ghprbActualCommit), ${context} (${subMessage}) is ${state}, see ${url}" 36 | return 37 | } 38 | 39 | try { 40 | GhprbGitHubAuth auth = GhprbTrigger.getDscp().getGitHubAuth(credentialsId); 41 | GitHub gh = auth.getConnection(currentBuild.rawBuild.getParent()); 42 | // Null out the auth object so that Jenkins doesn't potentially ask to serialize it 43 | auth = null 44 | GHRepository ghRepository = gh.getRepository(repository); 45 | // Null out the gh object so that Jenkins doesn't potentially ask to serialize it 46 | gh = null 47 | // Create the state 48 | ghRepository.createCommitStatus(commitSha, ghState, url, subMessage, context); 49 | // Null out the ghRepository object so that Jenkins doesn't potentially ask to serialize it 50 | ghRepository = null 51 | } 52 | catch (e) { 53 | echo "Failed to create commit status for sha ${commitSha}: ${e.getMessage()}" 54 | } 55 | } 56 | --------------------------------------------------------------------------------