drone / drone-node Goto Github PK
View Code? Open in Web Editor NEWNode client for the Drone API
License: Apache License 2.0
Node client for the Drone API
License: Apache License 2.0
Currently I'm implementing a new version for Drone 1.x.x, just to document it somehow and to discuss if this is needed, I want to mention which endpoints haven't been integrated so far. What do you think, do we need these endpoints at all?
GET /api/user/remote/repos
GET /api/user/remote/repos/{owner}/{name}
GET /api/stream
GET /api/stream/{owner}/{name}
GET /api/stream/{owner}/{name}/{number}/{stage}/{step}
If I use the client.promoteBuild
method with parameters then these are not available when the build executes.
It appears the root cause of this is that code at https://github.com/drone/drone-node/blob/master/lib/index.js#L331-L339 passes the parameters as part of the POST body, but the server expects them in the querystring (based on my reading of https://docs.drone.io/api/builds/build_promote/)
I tried making the same requests with curl
to validate this and if the params are sent in the query string then they appear correctly.
I would make this change myself since it should be fairly simple, but I don't know the API well enough to know which other methods are affected (I suspect there may be several).
need to write tests for all the things
The responses returned from the Client are the Axios responses rather than just the data from the response. I'm happy to PR the changes but wanted to be sure there wasn't a reason for this before doing the work.
I am really enjoying Drone. Keep up the great work
Hello, I would like to suggest that some form of TypeScript definitions be shipped with this library, because having the definitions can provide an incredible experience for developers who either already use TypeScript or devs who have tooling that can take advantage of the definitions. Putting them in this repository specifically would allow for API updates to remain in sync with their definitions.
In the API doc, it says:
Get the latest build
Returns the latest repository build.
GET /api/repos/{owner}/{name}/builds/{number}
In the drone-node
lib, the code to do so is:
getLastBuild(owner, name) {
Joi.assert(owner, Joi.string().required(), 'Must specify owner');
Joi.assert(name, Joi.string().required(), 'Must specify name');
return this._request('get', `/api/repos/${owner}/${name}/builds/latest`);
};
Note the endpoint it is calling: /api/repos/${owner}/${name}/builds/latest
, ending with 'latest' instead of '{number}'.
Using GET /api/repos/{owner}/{name}/builds/{number}
works perfectly.
However, GET /api/repos/${owner}/${name}/builds/latest
by calling that method Drone.getLastBuild(owner, name)
does not, as it returns the following error:
[Error: Invalid response code: 500]
statusCode: 500,
headers: {...}
]
Is it the doc that has a copy/paste mistake, in which {number}
should have been replaced by latest
, or this library is still calling a deprecated endpoint?
P.S: I am using a hosted Drone, v0.5.
Does the API already support pagination? If so it'd be great to support it in the getBuilds
function.
Line 178 in 70ba5eb
What is fork
ing for?
I'm trying to start a build that's already running (see output below), but drone just returns the standard JSON response from the running build and doesn't start the new build, even when trying to fork - is there a way to trigger another build from the current build?
So far I have tried using the GO and JS wrappers to no avail, and below is a log of trying directly curl
ing the REST API (it gives more of a response, but still doesn't trigger a new build):
.drone.yml
ipeline:
deploy:
image: repo/my-deploy:latest
secrets:
- ...
commands:
- export DRONE_DEPLOY_TO="$${DRONE_DEPLOY_TO:-dev}"
- ./entrypoint.sh
when:
event: [deployment, push]
branch: master
some_slack_notify_jobs:
...
promote_to_uat:
image: repo/my-deploy:latest
secrets:
- drone_token
commands:
- curl "https://$${DRONE_SERVER}/$${REPO_PATH}/builds/$${DRONE_BUILD_NUMBER}?fork=true&DRONE_DEPLOY_TO=uat&access_token=$${DRONE_TOKEN}"
when:
branch: master
event: push
status: success
...succeeds but doesn't trigger the new build, just exits cleanly with the following output:
curl ...
{
"id":6027,
"number":69,
"parent":0,
"event":"push",
"status":"running",
"error":"",
"enqueued_at":1517420554,
"created_at":1517420554,
"started_at":1517420554,
"finished_at":0,
"deploy_to":"",
"commit":"44be60f0d5d223e550f7116e1d36a3f44592dc65",
"branch":"master",
"ref":"refs/heads/master",
"refspec":"",
"remote":"",
"title":"",
"message":"Merge branch 'feature/...' into 'master'",
"timestamp":0,
"sender":"",
"author":"Robin Knipe",
"author_avatar":"...",
"author_email":"...",
"link_url":"",
"signed":false,
"verified":true,
"reviewed_by":"",
"reviewed_at":0,
"procs":[
{
"id":20796,
"build_id":6027,
"pid":1,
"ppid":0,
"pgid":1,
"name":"",
"state":"running",
"exit_code":0,
"start_time":1517420554,
"machine":"drone-agent-gitlab-3964423023-6m5mv",
"children":[
{
"id":20797,
"build_id":6027,
"pid":2,
"ppid":1,
"pgid":2,
"name":"default",
"state":"success",
"exit_code":0,
"start_time":1517420554,
"end_time":1517420569,
"machine":"drone-agent-gitlab-3964423023-6m5mv"
},
{
"id":20798,
"build_id":6027,
"pid":3,
"ppid":1,
"pgid":3,
"name":"deploy",
"state":"success",
"exit_code":0,
"start_time":1517420569,
"end_time":1517420604,
"machine":"drone-agent-gitlab-3964423023-6m5mv"
},
{
"id":20799,
"build_id":6027,
"pid":4,
"ppid":1,
"pgid":4,
"name":"notify_slack_success_push",
"state":"success",
"exit_code":0,
"start_time":1517420605,
"end_time":1517420606,
"machine":"drone-agent-gitlab-3964423023-6m5mv"
},
{
"id":20800,
"build_id":6027,
"pid":5,
"ppid":1,
"pgid":5,
"name":"notify_slack_failure_push",
"state":"pending",
"exit_code":0
},
{
"id":20801,
"build_id":6027,
"pid":6,
"ppid":1,
"pgid":6,
"name":"promote_to_uat",
"state":"running",
"exit_code":0,
"start_time":1517420606,
"machine":"drone-agent-gitlab-3964423023-6m5mv"
}
]
}
]
}
exit code 0
Is this lib working with latest drone version?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.