Hello there,
I am completely newbie to Drone, so any help/directions would be useful.
I am trying a POC to create a drone plugin and my requirements for plugin is as follows
The plugin should accept a json file
The json file should be posted using curl command to another service api
capture the response and read json value
based on the result, pipeline succeed or fails
The plugin should be reusable across drone pipelines
Should i first create a docker image first and push to artifactory and then reuse it? or can it be created on the fly and push to artifactory when running the pipeline?
It is possible to build a docker image in one step and use that image in a later step, but that probably isn’t what you want to do, if you are working on a plugin.
Usually plugins are built and published to a public docker registry, then pulled as the image: field in pipeline steps.
Is there a reason you want to use a plugin, rather than the official curl docker image?
You could add your own scripting in commands: rather than introduce the extra complexity involved with writing a Drone plugin.
Thanks for your response. Agree that we need repository and our org have the one to pull and push.
First time seeing curl image and will go through that, but does it allow to pass file as input parameter and additional parameters if any?
The reason is I need is that file to be passed to a service api as form file parameter(may be additional parameters as well)
I may be having little knowledge on this but what is the best way to pass the values that are generated in previous steps?
Sure thanks, will give a try. I too tried to run command without any docker image. My sample code below and it works fine(status 200) but I need to capture the response of the curl command.
steps:
name: curl
commands:
curl --request --location POST <my_api_url> --form “inputFile="<file_path>"”
but when I tried to capture the response with something like below, i get pipeline exited with error code 26( I could not find any additional details)
http_response = $(curl command as above)
am I missing anything? If not using a complex way to create docker image/plugin if I would be able to read the response / json for a particular value and do a If condition it would be great.
Else, if I can use those shell scripts inside a script file and execute it would be also nice
Yes it does work locally as well as in the pipeline, but I need to receive the http response and check some value from the returned json, that is where I need to use with curl command for now.
@jimsheldon ,
sorry for giving late reply. Yes the service is running outside of the drone infra.
As an update,
I was able to call shell script from drone pipeline and handle all the business logic inside it.
Next is to convert/move the logic inside a docker image and publish it if needed.