-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get current build artifact #147
Conversation
…als that the Jenkins API Client already knows about
Sure, |
An example could be found here. |
I'll take a look, my main stumbling block with Net::HTTP had been getting basic_auth to work when requesting the file. |
The |
so this works for me using Net::HTTP now instead of curl. I'd love feedback on how to clean it up if you have any. But it does accept a job and filename and download the current build artifact. |
request = Net::HTTP::Get.new(uri.request_uri) | ||
request.basic_auth(@username, @password) | ||
response = http.request(request) | ||
File.write(filename, response.body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File.expand_path(filename)
should be better so relative paths work cleanly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this is going to simply store the response body regardless of the response. So checking if the response code is a success (200) before saving the body should be good.
Thanks for reviewing and helping me clean that up. If anything else needs to be done let me know. I'll be happy to see this contribution available for other users. Hope it is helpful for all. |
@@ -21,6 +21,7 @@ | |||
# | |||
|
|||
require 'jenkins_api_client/urihelper' | |||
require 'net/https' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this library used in this file? If not it can be removed.
Made a couple minor comments. Once addressed, I'll merge and release another version. Thanks again for the contribution! |
Is this going to be merged? |
@howdoicomputer This will be merged shortly. |
Noted #61 and created a custom method to find and download the current build.
I'm sure it could use some cleanup I'd love to see what that is.
An example of how I'm using this can be seen here https://gist.github.com/joelneubert/19f607887a7246925a17