lib/omnibus/publishers/artifactory_publisher.rb
def build_for(packages)
      metadata = packages.first.metadata
      name     = metadata[:name]

      # Attempt to load the version manifest data from the packages metadata
      manifest = if version_manifest = metadata[:version_manifest]
                   Manifest.from_hash(version_manifest)
                 else
                   Manifest.new(
                     metadata[:version],
                     # we already know the `version_manifest` entry is
                     # missing so we can't pull in the `build_git_revision`
                     nil,
                     metadata[:license]
                   )
                 end

      # Upload the actual package
      log.info(log_key) { "Saving build info for #{name}, Build ##{manifest.build_version}" }

      Artifactory::Resource::Build.new(
        client: client,
        name:   name,
        number: manifest.build_version,
        vcs_revision: manifest.build_git_revision,
        build_agent: {
          name: "omnibus",
          version: Omnibus::VERSION,
        },
        modules: [
          {
            # com.getchef:chef-server:12.0.0
            id: [
              Config.artifactory_base_path.tr("/", "."),
              name,
              manifest.build_version,
            ].join(":"),
            artifacts: packages.map do |package|
              [
                {
                  type: File.extname(package.path).split(".").last,
                  sha1: package.metadata[:sha1],
                  md5: package.metadata[:md5],
                  name: package.metadata[:basename],
                },
                {
                  type: File.extname(package.metadata.path).split(".").last,
                  sha1: digest(package.metadata.path, :sha1),
                  md5: digest(package.metadata.path, :md5),
                  name: File.basename(package.metadata.path),
                },
              ]
            end.flatten,
          },
        ]
      )
    end
def build_for(packages)
      metadata = packages.first.metadata
      name     = metadata[:name]

      # Attempt to load the version manifest data from the packages metadata
      manifest = if version_manifest = metadata[:version_manifest]
                   Manifest.from_hash(version_manifest)
                 else
                   Manifest.new(
                     metadata[:version],
                     # we already know the `version_manifest` entry is
                     # missing so we can't pull in the `build_git_revision`
                     nil,
                     metadata[:license]
                   )
                 end

      # Upload the actual package
      log.info(log_key) { "Saving build info for #{name}, Build ##{manifest.build_version}" }

      Artifactory::Resource::Build.new(
        client: client,
        name:   name,
        number: manifest.build_version,
        vcs_revision: manifest.build_git_revision,
        build_agent: {
          name: "omnibus",
          version: Omnibus::VERSION,
        },
        modules: [
          {
            # com.getchef:chef-server:12.0.0
            id: [
              Config.artifactory_base_path.tr("/", "."),
              name,
              manifest.build_version,
            ].join(":"),
            artifacts: packages.map do |package|
              [
                {
                  type: File.extname(package.path).split(".").last,
                  sha1: package.metadata[:sha1],
                  md5: package.metadata[:md5],
                  name: package.metadata[:basename],
                },
                {
                  type: File.extname(package.metadata.path).split(".").last,
                  sha1: digest(package.metadata.path, :sha1),
                  md5: digest(package.metadata.path, :md5),
                  name: File.basename(package.metadata.path),
                },
              ]
            end.flatten,
          },
        ]
      )
    end
The build object that corresponds to this package.

 @param [Array<Package>] packages
   the packages to create the build from

 @return [Artifactory::Resource::Build]