Skip to content

Instantly share code, notes, and snippets.

@seif
Forked from anonymous/default.rb
Last active December 10, 2015 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seif/4389024 to your computer and use it in GitHub Desktop.
Save seif/4389024 to your computer and use it in GitHub Desktop.
tc = Teamcity::Utility.new(:server=>"#{node.teamcity.server}", :port => 80, :username => "#{node.teamcity.username}", :password => "#{node.teamcity.password}")
build_version = tc.get_latest_build('bt134')
teamcity_build_type = 'bt134'
teamcity_build "download-artefact" do
build_type teamcity_build_type
version build_version
destination "C:\\Temp\\#{teamcity_build_type}\\#{build_version}.zip"
overwrite true
action :download
not_if {::File.exists?("C:\\Temp\\#{teamcity_build_type}\\#{build_version}.zip")}
notifies :unzip, "windows_zipfile[unzip_artefacts]", :immediately
end
windows_zipfile "unzip_artefacts" do
path "C:\\Temp\\#{teamcity_build_type}\\#{build_version}\\"
source "C:\\Temp\\#{teamcity_build_type}\\#{build_version}.zip"
action :nothing
notifies :run, "windows_batch[run_dropkick]", :immediately
end
windows_batch "run_dropkick" do
code <<-EOH
cd C:\\Temp\\#{teamcity_build_type}\\#{build_version}\\Deployment
execute-#{node.chef_environment}-all.bat
EOH
action :nothing
end
Some lines ommited, previous recipes run ok, first line to do with recipe in gist is:
localhost [2012-12-27T15:18:09+00:00] INFO: Processing teamcity_build[download-artefact] action download (Wiggle_Billing::default line /chef/cache/cookbooks/Wiggle_Billing/recipes/default.rb)
localhost [2012-12-27T15:18:09+00:00] INFO: Downloading file to C:\Temp\bt134\1.8.8.zip. This may take a while...
localhost [2012-12-27T15:18:09+00:00] DEBUG: Starting HTTP session...
localhost [2012-12-27T15:18:09+00:00] DEBUG: Getting HTTP Response
localhost [2012-12-27T15:18:09+00:00] DEBUG: Response was successful with code 200
localhost [2012-12-27T15:18:09+00:00] DEBUG: Recursively creating C:\Temp\bt134\1.8.8.zip
localhost [2012-12-27T15:18:09+00:00] DEBUG: Downloaded chunk of size 8192
.... downloading chunks ommited.
localhost [2012-12-27T15:18:56+00:00] DEBUG: Downloaded chunk of size 1832
localhost [2012-12-27T15:18:56+00:00] DEBUG: Downloaded chunk of size 7424
localhost [2012-12-27T15:18:56+00:00] INFO: Processing windows_zipfile[unzip_artefacts] action nothing (Wiggle_Billing::default line /chef/cache/cookbooks/Wiggle_Billing/recipes/default.rb)
localhost [2012-12-27T15:18:56+00:00] DEBUG: Doing nothing for windows_zipfile[unzip_artefacts]
localhost [2012-12-27T15:18:56+00:00] INFO: Processing windows_batch[run_dropkick] action nothing (Wiggle_Billing::default line /chef/cache/cookbooks/Wiggle_Billing/recipes/default.rb)
localhost [2012-12-27T15:18:56+00:00] DEBUG: Doing nothing for windows_batch[run_dropkick]
localhost [2012-12-27T15:18:56+00:00] DEBUG: Saving the current state of node WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk
localhost [2012-12-27T15:18:56+00:00] DEBUG: Signing the request as WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk
localhost [2012-12-27T15:18:56+00:00] DEBUG: String to sign: 'Method:PUT
localhost Hashed Path:b6KjzXtcKL4GyQV4fIuhmAj56gY=
localhost X-Ops-Content-Hash:pu+/K4UEgWFWWm4kMWHdVHn4Ypc=
localhost X-Ops-Timestamp:2012-12-27T15:18:56Z
localhost X-Ops-UserId:WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk'
localhost Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk", "X-Ops-Timestamp"=>"2012-12-27T15:18:56Z", "X-Ops-Content-Hash"=>"pu+/K4UEgWFWWm4kMWHdVHn4Ypc=", "X-Ops-Authorization-1"=>"BmXy4TK2ft9TEvtEfUIjFyhwNC8ECr9OctQOoNTzqoI0mcyBgfr7cjzDYSnl", "X-Ops-Authorization-2"=>"4Jtdn7sVaX3xNfw+NkbDOEI7GPnAGj0B3slMruKW12vKEiLosX+0Ut+npLXD", "X-Ops-Authorization-3"=>"F97UsFoVfCeVuAJsqQ3L6B9huDwiX3c9WmOqnRwyUciZj5mkZi8CTmVdKgUF", "X-Ops-Authorization-4"=>"VGtbTnx5VnoCqOSSGfr4uCGtqab+nBKxDOi5uunZiR1EGH9LVLWSfDhD9SoV", "X-Ops-Authorization-5"=>"YbeEEQNNWb+yENqlziWgW5uUBP867v39Ogl9dGmnJvgYlY/x1faQp2kvi+Op", "X-Ops-Authorization-6"=>"WtF5GKxXqQoMBaJb1V+gNfl8pHGrOTzPQNDliPUhIw=="}
localhost [2012-12-27T15:18:56+00:00] DEBUG: Sending HTTP Request via PUT to api.opscode.com:443/organizations/attar/nodes/WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk
localhost [2012-12-27T15:18:58+00:00] DEBUG: ---- HTTP Status and Header Data: ----
localhost [2012-12-27T15:18:58+00:00] DEBUG: HTTP 1.1 200 OK
localhost [2012-12-27T15:18:58+00:00] DEBUG: server: nginx/1.0.5
localhost [2012-12-27T15:18:58+00:00] DEBUG: date: Thu, 27 Dec 2012 15:18:56 GMT
localhost [2012-12-27T15:18:58+00:00] DEBUG: content-type: application/json
localhost [2012-12-27T15:18:58+00:00] DEBUG: transfer-encoding: chunked
localhost [2012-12-27T15:18:58+00:00] DEBUG: connection: close
localhost [2012-12-27T15:18:58+00:00] DEBUG: content-encoding: gzip
localhost [2012-12-27T15:18:58+00:00] DEBUG: ---- End HTTP Status/Header Data ----
localhost [2012-12-27T15:18:58+00:00] DEBUG: decompressing gzip response
localhost [2012-12-27T15:18:58+00:00] INFO: Chef Run complete in 54.43666 seconds
localhost [2012-12-27T15:18:58+00:00] DEBUG: Cleaning the checksum cache
localhost [2012-12-27T15:18:58+00:00] DEBUG: Removing unused checksum cache file c:/chef/cache/checksums/chef-file-C
localhost [2012-12-27T15:18:58+00:00] INFO: Running report handlers
localhost [2012-12-27T15:18:58+00:00] INFO: Report handlers complete
localhost [2012-12-27T15:18:58+00:00] INFO: Sending resource update report (run-id: 316e33dcbcac99eaaaefc2f27a3078ef)
localhost [2012-12-27T15:18:58+00:00] DEBUG: {"action"=>"end", "resources"=>[{"type"=>"windows_registry", "name"=>"HKLM\\SOFTWARE\\Microsoft\\ServerManager", "id"=>"HKLM\\SOFTWARE\\Microsoft\\ServerManager", "after"=>{}, "before"=>{}, "duration"=>"0", "delta"=>"", "result"=>"modify", "cookbook_name"=>"wiggle", "cookbook_version"=>"0.1.0"}, {"type"=>"windows_registry", "name"=>"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\Reliability", "id"=>"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\Reliability", "after"=>{}, "before"=>{}, "duration"=>"16", "delta"=>"", "result"=>"modify", "cookbook_name"=>"wiggle", "cookbook_version"=>"0.1.0"}], "status"=>"success", "run_list"=>"[\"recipe[chef-client]\",\"role[base]\",\"role[Wiggle_Billing]\"]", "total_res_count"=>"22", "data"=>{}}
localhost [2012-12-27T15:18:58+00:00] INFO: run_data_summary: {"action"=>"end", "resources"=>[], "status"=>"success", "run_list"=>"[\"recipe[chef-client]\",\"role[base]\",\"role[Wiggle_Billing]\"]", "total_res_count"=>"22", "data"=>{}, "updated_res_count"=>"2", "post_size"=>"312"}
localhost [2012-12-27T15:18:58+00:00] DEBUG: Signing the request as WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk
localhost [2012-12-27T15:18:58+00:00] DEBUG: String to sign: 'Method:POST
localhost Hashed Path:5891TdNCMBBCoyXheuvK0naCpHU=
localhost X-Ops-Content-Hash:MGUiVScFgyBmdZ5p+fOIOsHGjX0=
localhost X-Ops-Timestamp:2012-12-27T15:18:58Z
localhost X-Ops-UserId:WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk'
localhost Header hash: {"X-Ops-Sign"=>"algorithm=sha1;version=1.0;", "X-Ops-Userid"=>"WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk", "X-Ops-Timestamp"=>"2012-12-27T15:18:58Z", "X-Ops-Content-Hash"=>"MGUiVScFgyBmdZ5p+fOIOsHGjX0=", "X-Ops-Authorization-1"=>"d3HB11uZs7HbllVZonNM/Ry2/FF8PpJ+nYIuRT/894aaM9wQwSz6aBa7QkRG", "X-Ops-Authorization-2"=>"jzOsuIrJrOT853KOC33yHvjsCOeND+3a8zVA6ad+wiczuIdbfNbcpU5FkMDe", "X-Ops-Authorization-3"=>"+r/s7O/625i8GMxKGgJvTOPWWLy+6QTLsaehfXqgGikpeAdW72iHOsx3Ukj+", "X-Ops-Authorization-4"=>"TbeiHAoTVPs80KClXgSe7HtjXXVP+bbkGSUCK2ZIcSpFwWvBp0634ik5nzk+", "X-Ops-Authorization-5"=>"mqk7+SGOjAj9dW6JEygYXh1zZcOvEH0mB4z6kJxox+x6WrmWgvIS+xF5UnOH", "X-Ops-Authorization-6"=>"LmvpHU3lv5uIKAskcQVRYw38MCc1xLureHGzHLn7ww=="}
localhost [2012-12-27T15:18:58+00:00] DEBUG: Sending HTTP Request via POST to api.opscode.com:443/organizations/attar/reports/nodes/WIN-5SMRIK4TSD7.wiggledomain.wiggle.co.uk/runs/316e33dcbcac99eaaaefc2f27a3078ef
localhost [2012-12-27T15:18:59+00:00] DEBUG: ---- HTTP Status and Header Data: ----
localhost [2012-12-27T15:18:59+00:00] DEBUG: HTTP 1.1 200 OK
localhost [2012-12-27T15:18:59+00:00] DEBUG: server: nginx/1.0.5
localhost [2012-12-27T15:18:59+00:00] DEBUG: date: Thu, 27 Dec 2012 15:18:57 GMT
localhost [2012-12-27T15:18:59+00:00] DEBUG: content-type: application/json
localhost [2012-12-27T15:18:59+00:00] DEBUG: connection: close
localhost [2012-12-27T15:18:59+00:00] DEBUG: content-length: 2
localhost [2012-12-27T15:18:59+00:00] DEBUG: ---- End HTTP Status/Header Data ----
localhost [2012-12-27T15:18:59+00:00] DEBUG: Exiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment