Drone-jsonnet not working

@ihakimi this is expected, you cannot curl the endpoint like this. The endpoint requires a signed request, per the http-signatures spec. So this error is expected.

this is what I see on the agent logs
2019/05/26 20:41:17 [DEBUG] POST opsys-drone-grpc://localhost:8080/rpc/v1/request: retrying in 10s (22 left)
2019/05/26 20:41:17 [ERR] POST opsys-drone-grpc://localhost:8080/rpc/v1/request request failed: Post opsys-drone-grpc:/

this is not a valid http endpoint. the scheme should be http or https, not opsys-drone-grpc. Also are you sure this is an issue with drone-jsonnet? Nothing about this error demonstrates a problem with drone-jsonnet. Is there additional information that leads you to believe this is a problem with drone-jsonnet that you are not providing?

maybe the issue is the connection between client-server, when I might misunderstand the grpc on the server port 9000
what should be the value for DRONE_RPC_SERVER?

this is what I am getting in the log
2019/05/26 20:50:33 [ERR] POST http://opsys-drone/rpc/v1/request request failed: Post http://opsys-drone/rpc/v1/request: context deadline exceeded
2019/05/26 20:50:33 [ERR] POST http://opsys-drone/rpc/v1/request request failed: Post http://opsys-drone/rpc/v1/request: context deadline exceeded
2019/05/26 20:50:33 [ERR] POST http://opsys-drone/rpc/v1/request request failed: Post http://opsys-drone/rpc/v1/request: context deadline exceeded

drone 1.0 does not use grpc and does not listen on 9000. In Drone 1.x the communication protocol is plain old http(s) on the standard ports.

also drone does long polling and after 30 seconds will cancel and then re-try the request. Those error messages can be completely normal. But if there is an issue there is extensive documentation to help you troubleshoot agent communication issues. See Builds are Stuck in Pending Status

either way, I do not see any evidence of issues with drone-jsonnet. If you still have issues with agent-to-server communication after reading the troubleshooting guide, please either search for an existing topic related to the errors you are seeing or start a new topic if none exists.

Ok, server-clinet working ablo to run pipeline using .drone.yml
I put on server DRONE_JSONNET_ENABLED: “true”
and when I change the file on setting to .drone.jsonnet nothing happened

this is the error for JSON
{“commit”:“55f7a8eb4cd42b578bee97a9810c9b731cbb762f”,“event”:“push”,“level”:“debug”,“msg”:“trigger: received”,“ref”:“refs/heads/11.11”,“repo”:“tlv-opsys/ops-deployer”,“time”:“2019-05-26T21:00:32Z”}
{“commit”:“55f7a8eb4cd42b578bee97a9810c9b731cbb762f”,“error”:“RUNTIME ERROR: stream mode: top-level object was a object, should be an array whose elements hold the JSON for each document in the stream.\n\tDuring manifestation\t\n”,“event”:“push”,“level”:“warning”,“msg”:“trigger: cannot find yaml”,“ref”:“refs/heads/11.11”,“repo”:“tlv-opsys/ops-deployer”,“time”:“2019-05-26T21:00:33Z”}
{“fields.time”:“2019-05-26T21:00:33Z”,“latency”:387489203,“level”:“debug”,“method”:“POST”,“msg”:"",“remote”:“10.207.4.133:48206”,“request”:"/hook",“request-id”:“832b7208105389c4818361f2a95e8e00”,“time”:“2019-05-26T21:00:33Z”}
{“fields.time”:“2019-05-26T21:00:39Z”,“latency”:1073729,“level”:“debug”,“method”:“GET”,“msg”:"",“remote”:“10.207.4.116:43140”,“request”:"/",“request-id”:“1Lms7Y4BUxe0LC5ePJXHkKM5yWx”,“time”:“2019-05-26T21:00:39Z”}
{“arch”:“amd64”,“kernel”:"",“level”:“debug”,“msg”:“manager: context canceled”,“os”:“linux”,“time”:“2019-05-26T21:00:41Z”,“variant”:""}

top-level object was a object, should be an array whose elements hold the JSON for each document in the stream

This appears to be a jsonnet parsing error. Please provide the jsonnet file. Specifically the jsonnet file should return an array.

local docker(name, branch, tag) = {
name: name,
image: “plugins/docker”,
settings: {
repo: “octocat/hello-world”,
tags: tag,
when: {
branch: branch
}
}
};

{
kind: “pipeline”,
name: “default”,
steps: [
{
name: “build”,
image: “golang”,
commands: [ “go build”, “go test” ],
},
docker(“build-master”, “master”, “latest”),
docker(“build-develop”, “develop”, “develop”),
]
}

this is from example

can you format the code snippet for better readability?

It looks like you are not returning an array. The jsonnet file should end with an array. Since the final character in the jsonnet appears to be a } this would tell me you are returning an object and not an array.

yep, you need to return an array [], so wrap your return object in an array

thanks works!!! regarding jsonnet I first configure it using the plugin but then I saw it already pluggeable on 1.0.0 so worth to mention it on the docs people will know

just be aware when drone cli I am getting the following error
2019/05/27 00:25:57 yaml: unmarshal errors:
line 1: cannot unmarshal !!seq into yaml.RawResource

but on the server everything is working

00:26 $ drone --version
drone version 1.1.0

when using the CLI you need drone jsonnet --stream

I also get this error

yaml: line 2: mapping values are not allowed in this context

I don’t really understand why you started to comment about CURL and CLI commands. The problem is when I put a clear object in .drone.jsonnet everything goes fine:

{
"kind": "pipeline",
"type": "docker",
"name": "default",
"steps": [
    {
        "name": "build",
        "image": "alpine",
        "commands": [
            "echo hello world",
        ]
    }
]

}

But when I prepend it with any function it causes this error. Example:

local build(env) = {
  name: "build",
  image: "node:14.9.0",
  commands: [
    "yarn run build",
  ]
};

{
    "kind": "pipeline",
    "type": "docker",
    "name": "default",
    "steps": [
        build("hi")
    ]
}

Log errors:

{"commit":"b23aa7a47f0b0f016562e828842c7e90a44ef49c","error":"yaml: line 1: mapping values are not allowed in this context","event":"push","level":"warning","msg":"trigger: cannot parse yaml","ref":"refs/heads/feature/drone","repo":"schain/frontend","time":"2020-10-31T10:02:00Z"

And yes I changed repo setting to .drone.jsonnet surely

$ drone --version
drone version 1.2.2

the jsonnet conversion was previously handled by an external microservice [1], and in this comment the individual was trying to curl the microservice with an unsigned http request.

But when I prepend it with any function it causes this error.
And yes I changed repo setting to .drone.jsonnet surely

This happens if you do not enable jsonnet support on your server. You can enable jsonnet support on your server by setting the DRONE_JSONNET_ENABLED flag to true.

[1] https://github.com/drone/drone-jsonnet-config
[2] https://docs.drone.io/server/reference/drone-jsonnet-enabled/

1 Like