Sha256: 8b3222fa7be364bc4eabc8e43be644eeacd5671bd137e69b8e653f2f89b9cda1

Contents?: true

Size: 1.69 KB

Versions: 24

Compression:

Stored size: 1.69 KB

Contents

module Pkg::Nuget
  class << self
    def ship(packages)
      #
      # Support shipping of Nuget style packages to an Artifactory based nuget feed
      # Using curl to submit the packages rather than windows based choco/mono.
      # This approach gives more flexibility and fits in with the current Puppet
      # release automation practices using linux/mac systems.

      # Sanity checks
      fail "NUGET_HOST is not defined" if Pkg::Config.nuget_host.empty?
      fail "NUGET_REPO is not defined" if Pkg::Config.nuget_repo_path.to_s.empty?

      # Retrieve password without revealing it
      puts "Obtaining credentials to ship to nuget feed #{Pkg::Config.nuget_repo_path} on #{Pkg::Config.nuget_host}"
      print "Username please: "
      username = Pkg::Util.get_input(true)
      print "Password please: "
      password = Pkg::Util.get_input(false)
      authentication = Pkg::Util.base64_encode("#{username}:#{password}")

      uri = "#{Pkg::Config.nuget_host}#{Pkg::Config.nuget_repo_path}"
      form_data = ["-H 'Authorization: Basic #{authentication}'", "-f"]
      packages.each do |pkg|
        puts "Working on package #{pkg}"
        projname, version = File.basename(pkg).match(/^(.*)-([\d+.]+)\.nupkg$/).captures
        package_form_data = ["--upload-file #{pkg}"]
        package_path = "#{projname}/#{version}/#{File.basename(pkg)}"
        stdout = ''
        retval = ''
        Pkg::Util::Execution.retry_on_fail(:times => 3) do
          stdout, retval = Pkg::Util::Net.curl_form_data("#{uri}/#{package_path}", form_data + package_form_data)
        end
        fail "The Package upload (curl) failed with error #{retval}" unless Pkg::Util::Execution.success?(retval)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
packaging-0.122.3 lib/packaging/nuget.rb
packaging-0.122.2 lib/packaging/nuget.rb
packaging-0.122.1 lib/packaging/nuget.rb
packaging-0.122.0 lib/packaging/nuget.rb
packaging-0.121.0 lib/packaging/nuget.rb
packaging-0.120.0 lib/packaging/nuget.rb
packaging-0.118.0 lib/packaging/nuget.rb
packaging-0.117.0 lib/packaging/nuget.rb
packaging-0.116.0 lib/packaging/nuget.rb
packaging-0.115.0 lib/packaging/nuget.rb
packaging-0.114.0 lib/packaging/nuget.rb
packaging-0.113.0 lib/packaging/nuget.rb
packaging-0.112.0 lib/packaging/nuget.rb
packaging-0.111.0 lib/packaging/nuget.rb
packaging-0.110.1 lib/packaging/nuget.rb
packaging-0.110.0 lib/packaging/nuget.rb
packaging-0.109.7 lib/packaging/nuget.rb
packaging-0.109.6 lib/packaging/nuget.rb
packaging-0.109.5 lib/packaging/nuget.rb
packaging-0.109.4 lib/packaging/nuget.rb