1.0.0-rc.1 Redirect and escaping inside command

As soon as I add a redirect (">") to a command, the pipeline doesn’t even start. When I try to escape (either with " or ') it doesn’t work either.
So i tried around and it seems, that spaces between sourcecommand > andtarget are the problem, while sourcecommand>andtarget works. I guess that is a bug? And shouldn’t there be an escaping mechanism?

Please provide full samples as I am unable to reproduce based on the description you have provided. This yaml works fine:

kind: pipeline
name: default

steps:
- name: build
  image: alpine
  commands:
  - echo foo.txt > bar

and this yaml works fine:

kind: pipeline
name: default

steps:
- name: build
  image: alpine
  commands:
  - "echo foo.txt > bar"

You can also triage this directly by looking at our yaml parser code, which has plenty of examples and unit tests: https://github.com/drone/drone-yaml

I guess that is a bug

I would need a reproducible example to come to this conclusion. But even if the yaml fails to parse and it is a bug, that bug would exist in the official go-yaml parser library (used by Drone, Kubernetes, etc) which we do not directly control.

The lack of error message displayed in the user-interface is known. We have not added the error to the user-interface yet. There are some pending user-interface tasks that you can follow here: https://github.com/drone/drone-ui/projects/2

Example:

kind: pipeline
name: default

steps:
- name: demo
  image: testsolutions/alpine-ssh-git:3.8
  commands:
  - ssh-keyscan -t rsa login.hpc.cs.uni-potsdam.de >> ~/.ssh/known_hosts
  - cat ~/.ssh/known_hosts

Result: https://drone.onpremise.testsolutions.de/boredland/nodejs-api-example/11

And shouldn’t there be an escaping mechanism?

there is an escaping mechanism, here: drone-yaml/script_posix.go at master · drone/drone-yaml · GitHub

I can rule out any issues with >> because this works just fine:

kind: pipeline
name: default

steps:
- name: demo
  image: alpine
  commands:
  - echo hello >> greeting.txt
  - cat greeting.txt

I then tried with this yaml:

kind: pipeline
name: default

steps:
- name: demo
  image: alpine
  commands:
  - apk add -qU openssh
  - mkdir -p /root/.ssh/
  - ssh-keyscan -t rsa login.hpc.cs.uni-potsdam.de >> ~/.ssh/known_hosts
  - cat ~/.ssh/known_hosts

and everything worked as expected:

I cannot reproduce any issues with drone at this juncture, but all the source involved in yaml parsing and pipeline execution is available (below). The easiest way to debug and develop locally is using the CLI

I do not think i will be able to provide any further assistance as I cannot reproduce, but would certainly welcome a patch if you are able to identify an issue.

Thank you so much. After I was able to reproduce it working with what you did, I looked into what differs in my image coming from alpine.
For some reason I can’t remember the testsolutions/alpine-ssh-git:3.8 contains bash. When bash is installed, the error gets reproducible:

steps:
- name: demo
  image: alpine:3.8
  commands:
  - apk add -qU bash ca-certificates curl rsync openssh git
  - mkdir -p /root/.ssh/
  - ssh-keyscan -t rsa login.hpc.cs.uni-potsdam.de >> ~/.ssh/known_hosts
  - cat ~/.ssh/known_hosts

BUT it isn’t only bash. If I just do

steps:
- name: demo
  image: alpine:3.8
  commands:
  - apk add -qU bash openssh
  - mkdir -p /root/.ssh/
  - ssh-keyscan -t rsa login.hpc.cs.uni-potsdam.de >> ~/.ssh/known_hosts
  - cat ~/.ssh/known_hosts

it works. :space_invader: