Last active
October 6, 2017 12:17
-
-
Save jplindgren/08bccc99ecfb08ee6b39 to your computer and use it in GitHub Desktop.
provisioning jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#variables | |
$url = 'http://localhost:8080/jnlpJars/jenkins-cli.jar'; | |
$jenkinsTempCliDir = Join-Path $env:TEMP "jenkinsClient" | |
if (![System.IO.Directory]::Exists($jenkinsTempCliDir)) {[System.IO.Directory]::CreateDirectory($jenkinsTempCliDir)} | |
$file = Join-Path $jenkinsTempCliDir "jenkins-cli.jar" | |
#functions | |
function Download-File { | |
param ( [string]$url, [string]$file ) | |
Write-Host "URL - $url" | |
Write-Host "File - $file" | |
$downloader = new-object System.Net.WebClient | |
$downloader.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials; | |
$downloader.DownloadFile($url, $file) | |
} | |
#Script! | |
param( [String]$waitJenkins = 20, [String]$jenkinsVersion = "1.552.0.0" ) | |
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')); | |
cinst googlechrome; | |
$chromePath = "${Env:ProgramFiles(x86)}\Google\Chrome\Application\" | |
$chromeApp = "chrome.exe" | |
$chromeCommandArgs = "--make-default-browser" | |
& "$chromePath$chromeApp" $chromeCommandArgs | |
cinst javaruntime -force; | |
cinst jenkins -Version $jenkinsVersion -force; | |
start-service jenkins; | |
#download jenkins-cli.jar | |
Download-File $url $file | |
#go to specific firectory to execute jenkins-cli.jar | |
pushd $jenkinsTempCliDir | |
#10 seconds to give time to jenkins start | |
Start-Sleep -s $waitJenkins | |
#install plugins | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin http://updates.jenkins-ci.org/download/plugins/greenballs/1.14/greenballs.hpi; | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin http://updates.jenkins-ci.org/download/plugins/msbuild/1.23/msbuild.hpi; | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin http://updates.jenkins-ci.org/download/plugins/mstest/0.7/mstest.hpi; | |
#github plugin and dependencies | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin https://updates.jenkins-ci.org/download/plugins/credentials/1.15/credentials.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin https://updates.jenkins-ci.org/download/plugins/ssh-credentials/1.7.1/ssh-credentials.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin https://updates.jenkins-ci.org/download/plugins/scm-api/0.2/scm-api.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin https://updates.jenkins-ci.org/download/plugins/multiple-scms/0.3/multiple-scms.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin https://updates.jenkins-ci.org/download/plugins/git-client/1.10.1/git-client.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin https://updates.jenkins-ci.org/download/plugins/github-api/1.56/github-api.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin https://updates.jenkins-ci.org/download/plugins/ssh-agent/1.4.1/ssh-agent.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin https://updates.jenkins-ci.org/download/plugins/git/2.2.4/git.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin http://updates.jenkins-ci.org/download/plugins/github/1.9.1/github.hpi; | |
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin http://updates.jenkins-ci.org/download/plugins/jobConfigHistory/2.8/jobConfigHistory.hpi | |
java -jar jenkins-cli.jar -s http://localhost:8080/ restart; | |
#back to original directory | |
popd | |
#open jenkins url in a browser | |
(new-object -com shell.application).Open("http://localhost:8080"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
at the line 47, why to use such an old version?