I have a ruby script to upload files to a Jenkins job but for some reason 
they don't appear in the job's workspace.

def jenkins_get_attempt(credentials, uri,payload)

    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE

    headers = {'Content-Type' => "application/json", 'Accept-Encoding'=> 
"gzip,deflate",'Accept' => "application/json" }

    request = Net::HTTP::Post.new(uri.request_uri,headers)
    request.basic_auth credentials.username, credentials.password
    request.body = payload.to_json

    begin
        response = http.request(request)
        puts response.body
        puts response.code
    rescue StandardError, Timeout::Error => e
        puts "Failed to get the resource: " + e.message
    end

   return response.is_a?(Net::HTTPSuccess)
end


###############################################################################
# Deploy a build file to Jenkins
# 
# @param credentials  [in] Jenkins credentials
# @param fileName     [in] name of the file to deploy
#
###############################################################################
def deploy_jenkins_ininspotability_ion_build(credentials,binZip, 
staticMediaZip)

    host = our_jenkins_host:8443
    token = "token"

    job = "/job/{our job}/build"

    uri= "https://"; + host
    uri << job
    uri << "?token=" + token
    uri << "&SERVICE_BIN="
    uri << File.basename(binZip)
    uri << "&SHARED_RESOURCES="
    uri << File.basename(staticMediaZip)
    uri << "&file0="
    uri << binZip
    uri << "&file1="
    uri << staticMediaZip

     payload = {
                  :parameter => [{:name => "binary_zip", :file => 
"file0"},{:name => "resources_zip",:file => "file1"}, {:name => 
"SERVICE_BIN", :value => File.basename(binZip)}, {:name => 
"SHARED_RESOURCES", :value => staticMediaZip }]
                 
               }

    puts "URI = " + uri;

    #uri = URI.parse(uri)

    attempt = 0
    maxAttempts = 10

    begin
        if jenkins_get_attempt(credentials, uri, payload, binZip, 
staticMediaZip)
            return true
        end
        
        attempt += 1

        puts "attempt #{attempt} failed"

    end while attempt < maxAttempts

    return false
end

The SERVICE_BIN and SHARED_RESOURCES values are populated, but the zip 
files don't get uploaded.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/78b19185-b64c-4342-9263-e797fc9bbf0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to