Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Example rake task that downloads CI artifacts to publish nuget packages to the official feed

View publish_nuget.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
desc "Downloads from CI and pushes nuget packages to the official feed"
task :release, [:package] do |t, args|
require 'open-uri'
release_path = "#{buildsupport_path}/nuget_release"
clean_dir release_path
 
# The @teamcity_build_id is a unique identifier for the build configuration (looks like "bt234"). You can usually figure it out from your project url
artifact_url = "http://teamcity.codebetter.com/guestAuth/repository/downloadAll/#{@teamcity_build_id}/.lastSuccessful/artifacts.zip"
puts "downloading artifacts from teamcity.codebetter.com"
artifact = open(artifact_url)
unzip_file artifact.path, release_path
FileList["#{release_path}/*.nupkg"].exclude(".symbols.nupkg").each do |nupkg|
next if args[:package] && Nuget.package_name(nupkg).downcase != args[:package].downcase
sh "#{nuget} push #{nupkg}" do |ok, res|
puts "May not have published #{nupkg}" unless ok
end
end
end
 
def clean_dir(path)
mkdir_p path, :verbose => false
rm_r Dir.glob(File.join(path, "*.*")), :verbose => false
end
def unzip_file (file, destination)
require 'rubygems'
require 'zip/zip'
Zip::ZipFile.open(file) { |zip_file|
zip_file.each { |f|
f_path=File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(f_path))
zip_file.extract(f, f_path) unless File.exist?(f_path)
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.