I'm looking for an "event-driven" way to use travis, I need to notify him when something occurred but in the meanwhile the build should be in 'yellow' state, it may takes up to 2 hours.
Does anybody knows a way? or another CI supports that?
Thanks!
You can trigger builds using travis API.
For example, to trigger a build for the most recent commit, you can send the following POST request:
body='{
"request": {
"branch":"master"
}}'
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token xxxxxx" \
-d "$body" \
https://api.travis-ci.com/repo/travis-ci%2Ftravis-core/requests
Related
I am trying to write a Bash script on my server (My Server) that will grab a file from one remote server (Source) and copy it to a Dropbox account (Destination). I need to get the file from Source via SFTP and will be copying it to Destination using the Dropbox API (HTTPS). So far I can get the file with:
curl -k "sftp://Source/file.txt" --user "me:mypasswd" -o "/test/file.txt" --ftp-create-dirs
and then copy it to Dropbox with
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer " \
--header "Dropbox-API-Arg: {\"path\": \"/path/to/file.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary #/test/file.txt
I'm guessing the "right" way to do this is to pipe the file from Source directly to Destination, but I'm just not sure how to go about putting them together.
This is definitely not my area of expertise, so I don't even know where to start - nested CURL calls? If anyone could point me in the right direction, I'd be most appreciative.
UPDATE
Here's the whole curl command I'm running:
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer $token" \
--header "Dropbox-API-Arg: {\"path\": \"/xfer/chef.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary "$(curl -k "http://marketing.dave0112.com/file.txt" --user "me:mypasswd")"
I was having issues with CURL not supporting SFTP so I changed to HTTP while i get that end sorted out. Not sure if that affects anything.
You can replace this line :
--data-binary #/test/file.txt
with
--data-binary #<(curl -k "sftp://Source/file.txt" --user "me:mypasswd")
If problems, try :
--data-binary "$(curl -k "sftp://Source/file.txt" --user "me:mypasswd")"
I want to download files(*.txt and *.pdf) from Ariba site through GET api request and want to automate the whole download process.
Initially I have used Postman for testing purpose which gives me result in the form of file content.
For eg. test.txt file is present on remote site, after GET request from Postman, the result I am getting, it is in form of content of file, so if 'abc' is written in file, I am getting 'abc' as response from test.txt file.
Now if I click on Send and Download button in Postman it gives me option to download file 'test.txt'
I have to automate this process to send GET response and get required file download at specific location. I am trying to use Curl script for this.
I have written corresponding Curl script and tried to execute it.
It gives me response in the form of file content.
curl -X GET \
'https://openapi.ariba.com/api/approval/v1/prod/invoices/INVASINV6-902/attachments/bnMyMDE5LzA0LzAzLzE1MjkyNDE4MQ==?realm=ProjectName&Content-Disposition=attachement' \
-H 'Accept: */*' \
-H 'Authorization: Bearer 7648d29a-db04-4046-b49c-5daed43a145c' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: openapi.ariba.com' \
-H 'accept-encoding: gzip, deflate' \
-H 'apiKey: xxxxxxxxxxxxxxxxxx' \
-H 'cache-control: no-cache'
I want to write a curl script which will download file at specific location.
For eg. Above curl command give content(abc) from file Test.txt and not file Test.txt as output
Really appreciate your helpCurl Get Response
Postman Get Response
Finally I got answer to the question, I just need to remove -X GET from my curl script and at the end add -o to download file name.
Below is the final code:
curl 'https://openapi.ariba.com/api/approval/v1/prod/invoices/INVASINV6-902/attachments/bnMyMDE5LxxxxLzE1MjkyNDE4MQ==?realm=ProjectName' \
-H 'Accept: */*' \
-H 'Authorization: Bearer 77876887-xxxxx-42fb-b865-9cf8ff5c2b25' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: openapi.ariba.com' \
-H 'accept-encoding: gzip, deflate' \
-H 'apiKey: XXXXXXXXXXXXXXXX' \
-H 'cache-control: no-cache' \
-H 'Content-Type: application/octet-stream' \
-H "Content-Transfer-Encoding: Binary" \
-o "Test.txt"
Above code give me file downloaded at specific location.
Thanks BlackPearl.
I've tried just about every combination of single quotes, double quotes and backslashes that I can think of. If anyone could please point out what I'm doing wrong that'd be greatly appreciated.
run_locally do
execute "\\curl -X POST \"https://api.cloudflare.com/client/v4/zones/#{fetch(:cloudflare_zone)}/purge_cache\" \
-H \"X-Auth-Email: test#example.com\" \
-H \"X-Auth-Key: #{fetch(:cloudflare_api)}\" \
-H \"Content-Type: application/json\" \
--data {\"purge_everything\":true}\""
end
My capistrano script dies when it hits this every time. I feel like it's that last line but I'm not sure why.
Edit: I've gotten past that error, but now get "Malformed JSON in request body" back from Cloudflare.
run_locally do
execute "\\curl -X POST \"https://api.cloudflare.com/client/v4/zones/#{fetch(:cloudflare_zone)}/purge_cache\" \
-H \"X-Auth-Email: test#example.com\" \
-H \"X-Auth-Key: #{fetch(:cloudflare_api)}\" \
-H \"Content-Type: application/json\" \
--data \"{\"purge_everything\":true}\" "
end
So for some reason it doesn't like my --data section.
I'm not able to check this directly for you, but you can use other string constructs to do this in a clearer way which will hopefully highlight the issue for you.
run_locally do
execute %{curl -X POST "https://api.cloudflare.com/client/v4/zones/#{fetch(:cloudflare_zone)}/purge_cache" \
-H "X-Auth-Email: test#example.com" \
-H "X-Auth-Key: #{fetch(:cloudflare_api)}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'}
end
It's probably the nested double quotes in your JSON causing the issue.
Is it possible to use a URL in both a message and an activity in Yammer ?
Using the messages API, it is possible to construct a message which is:
Properly linked (in this example clicking on Title goes to example.com/id/1/); and
Includes an image (placehold.it/100x100).
For example:
#!/bin/bash
GROUP={GROUP}
TOKEN={TOKEN}
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
--data "body=hello" \
--data "group_id=$GROUP" \
--data "og_fetch=false" \
--data "og_url=http%3A%2F%2Fwww.example.com%2Fid%2F2%2F" \
--data "og_title=Title" \
--data "og_image=http%3A%2F%2Fplacehold.it%2F100x100" \
--data "og_description=Description" \
--data "og_object_type=page" \
--data "og_private=true" \
https://www.yammer.com/api/v1/messages.json
Using the activity API it is possible to make an Open Graph object:
Example:
#!/bin/bash
TOKEN={TOKEN}
EMAIL={EMAIL}
curl -X POST \
-H "Content-type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"activity":{"actor":{"email":"'$EMAIL'"},"action":"create","object":{"url":"http://www.example.com/id/1/","image":"http://placehold.it/110x110","title":"Title","type":"page"}},"private":"false","message":"This is an update"}' \
https://www.yammer.com/api/v1/activity.json
The problem is that now the original message from Step 1:
No longer links to the actual content (it links to https://www.yammer.com/{network}/graph/{id})
Loses its image (it is now mug0.assets-yammer.com/mugshot/images/75x75/3rd_party.png)
As an aside, the open graph object doesn't update for the new image provided in the activity post (110x110 vs 100x100). The docs (https://developer.yammer.com/v1.0/docs/open-graph) say "when an OG object exists (with the same URL), it is updated appropriately."
In one example you have the open graph object set to private and the other is to public. That may be causing the weird issue you are seeing.
"og_private=true"
I am trying to follow this example: http://docs.stormpath.com/rest/quickstart/
One of the steps mentions to do the following cURL request:
curl -X POST --user $YOUR_API_KEY_ID:$YOUR_API_KEY_SECRET \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name" : "My Awesome Application"
}' \
'https://api.stormpath.com/v1/applications?createDirectory=true'
I am using online cURL from : http://onlinecurl.com/
Here is the snapshot of the curl request:
Here is the snapshot of the Header Response:
Can anybody please tell me what is wrong?
I'm also having problems with that tool. I tried what you show in your screenshot, plus some other combinations. I actually get a different error (media type unauthorized). I suspect this tool uses some kind of proxy that is messing with the request.