# Drone cli output is different from jsonnet cli

**URL:** <https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118>\
**Category:** Drone Support\
**Created:** [November 23, 2020, 6:08pm UTC](https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118 "2020-11-23T18:08:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![0kk](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/0kk/32/2919_2.png) [@0kk](https://drone.discourse.group/u/0kk)\
**Post date:** [November 23, 2020, 6:08pm UTC](https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118/1 "2020-11-23T18:08:37Z")

</div>

I’m trying to migrate our dronefiles from yaml to jsonnet and I’m finding some odd behaviours from the drone cli.

Here is a simple jsonnet file.

```
local Pipeline(name) = {
  kind: 'pipeline',
  type: 'kubernetes',
  name: name,
  steps: [
    {
      name: 'publishToEcr',
      image: 'plugins/ecr',
      settings: {
        dockerfile: 'service1/Dockerfile',
        access_key: {
          from_secret: 'aws_access_key_id',
        },
        secret_key: {
          from_secret: 'aws_secret_access_key',
        },
        repo: 'drone-test/service1',
        registry: '1234556.dkr.ecr.us-east-1.amazonaws.com',
        region: 'us-east-1',
        tags: [
          '${DRONE_COMMIT_SHA:0:8}',
          '${DRONE_BRANCH}',
        ],
      },
    },
  ],
};

local whenCommitToNonMaster(step) = step {
  when: {
    event: ['push'],
    branch: {
      exclude: ['master'],
    },
  },
};

[
  whenCommitToNonMaster(Pipeline('A')),
  Pipeline('B'),
  Pipeline('C'),
]

```

when I run

```auto
drone jsonnet --stream --stdout

```

I don’t get the `when:` stanza at the Pipeline(‘A’) for some reasons.

but at the same time if I use the jsonnet cli I get the intended behaviour and the `when:` stanza appears at Pipeline(‘A’)

```auto
jsonnet .drone.jsonnet

```

also there are some functions from the [jsonnet Standard Library](https://jsonnet.org/ref/stdlib.html) that make drone cli panic like `std.parseJson` and others.

---

<div class="post-metadata">

**Author:** ![csgitharness](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/csgitharness/32/904_2.png) [@csgitharness](https://drone.discourse.group/u/csgitharness)\
**Post date:** [November 24, 2020, 11:51am UTC](https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118/2 "2020-11-24T11:51:04Z")

</div>

Hello , Kindly share the drone cli version and also could you try $ drone jsonnet --stdout --stream

> **[drone jsonnet | Drone](https://docs.drone.io/cli/drone-jsonnet/)**

---

<div class="post-metadata">

**Author:** ![0kk](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/0kk/32/2919_2.png) [@0kk](https://drone.discourse.group/u/0kk)\
**Post date:** [November 24, 2020, 10:30pm UTC](https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118/3 "2020-11-24T22:30:47Z")

</div>

> [@Documentation for 0.7 version](https://drone.discourse.group/t/documentation-for-0-7-version/8395/2):
>
> drone jsonnet --stdout --stream

```auto
[I] ➜ testjsonnet drone jsonnet --stdout --stream
2020/11/25 00:30:17 RUNTIME ERROR: Field does not exist: parseJson
	.drone.jsonnet:13:22-35	function <splitter_env>
	.drone.jsonnet:136:16-34	object <anonymous>
	<std>:1245:30-34	thunk from <thunk from <function <anonymous>>>
	<std>:1239:24-25	thunk from <thunk <t> from <function <anonymous>>>
	<std>:1239:15-26	thunk <t> from <function <anonymous>>
	<std>:1240:8-9	function <anonymous>

	<std>:1245:20-35	thunk from <function <anonymous>>
	<std>:1231:10-11	function <isContent>

	<std>:1245:10-36	function <anonymous>
		builtin function <flatMap>

	.drone.jsonnet:(133:36)-(140:3)	function <service>
	.drone.jsonnet:355:5-88	thunk from <object <anonymous>>
	During manifestation

```

```auto
[I] ➜ testjsonnet drone --version
drone version 1.2.4

```

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [November 24, 2020, 10:44pm UTC](https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118/4 "2020-11-24T22:44:32Z")

</div>

> [@Documentation for 0.7 version](https://drone.discourse.group/t/documentation-for-0-7-version/8395/1):
>
> I don’t get the `when:` stanza at the Pipeline(‘A’) for some reasons.

the _when_ stanza can be added to steps, however, in the above example you are adding the _when_ stanza to the pipeline, which is why it is being ignored. Perhaps you intended to add the _trigger_ stanza to the pipeline instead?

source: [Triggers | Drone](https://docs.drone.io/pipeline/docker/syntax/trigger/)

```diff
local whenCommitToNonMaster(step) = step {
- when: {
+ trigger: {
    event: ['push'],
    branch: {
      exclude: ['master'],
    },
  },
};

```

---

<div class="post-metadata">

**Author:** ![0kk](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/0kk/32/2919_2.png) [@0kk](https://drone.discourse.group/u/0kk)\
**Post date:** [November 25, 2020, 12:45am UTC](https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118/5 "2020-11-25T00:45:24Z")

</div>

yes that was the problem indeed thanks a lot. But the `parseJson` problem still happening tho. drone cli panics when I add it even tho it’s on the [jsonnet std](https://jsonnet.org/ref/stdlib.html)

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [November 25, 2020, 1:54am UTC](https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118/6 "2020-11-25T01:54:43Z")

</div>

> even tho it’s on the [jsonnet std](https://jsonnet.org/ref/stdlib.html)

the command line tools uses an older version of jsonnet-go which is probably why the function does not exist, since it was not yet part of the standard library at that time. If you are interested in upgrading the jsonnet module used by the command line tools, please consider sending a pull request to [github.com/drone/drone-cli](https://github.com/drone/drone-cli).

---

<div class="post-metadata">

**Author:** ![0kk](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/0kk/32/2919_2.png) [@0kk](https://drone.discourse.group/u/0kk)\
**Post date:** [November 25, 2020, 10:31am UTC](https://drone.discourse.group/t/drone-cli-output-is-different-from-jsonnet-cli/11118/7 "2020-11-25T10:31:36Z")

</div>

> [@Documentation for 0.7 version](https://drone.discourse.group/t/documentation-for-0-7-version/8395/6):
>
> please consider sending a pull request to

Someone already did it. Can it get reviewed please? [Bump google/go-jsonnet to v1.16.0 by guessi · Pull Request #174 · harness/drone-cli · GitHub](https://github.com/drone/drone-cli/pull/174)
