Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiline command #10

Closed
CAMOBAP opened this issue Jul 30, 2020 · 9 comments
Closed

Support multiline command #10

CAMOBAP opened this issue Jul 30, 2020 · 9 comments

Comments

@CAMOBAP
Copy link

CAMOBAP commented Jul 30, 2020

It looks like multiline command doesn't work

Is there any plan to support it

@drdanz
Copy link

drdanz commented Nov 19, 2020

I think this is an issue on windows only... on linux and mac this works for me:

    - name: Foo
      uses: nick-invision/retry@v2
      with:
        timeout_minutes: 5
        max_attempts: 3
        command: |
          command_1 \
            command_1_continued
          command_2

Apparently on windows it is using cmd instead of powershell to execute the command (see also #28).
Perhaps the string containing the command might be using only \n and not \r\n, therefore it is recognised as a single command by cmd?

@drdanz
Copy link

drdanz commented Nov 19, 2020

Probably not relevant, but inside the log, the commands are not aligned properly

Run nick-invision/retry@v2.2.0
  with:
    timeout_minutes: 10
    retry_wait_seconds: 1
    max_attempts: 3
    command: echo "test 1"
  echo "test 2"

@drdanz
Copy link

drdanz commented Nov 20, 2020

I found a workaround! This works properly:

    - name: Foo
      if: runner.os == 'Windows'
      uses: nick-invision/retry@v2.2.0
      with:
        timeout_minutes: 10
        retry_wait_seconds: 1
        max_attempts: 3
        command: >-
          echo "this is command 1" &
          echo "this is command 2"

It is definitely something related to the end of lines, >- removes all the end of lines, and the commands are separated by &
This accepts the cmd syntax though, therefore comments using # are not accepted and using rem will eat the rest of the command. It's not pretty, but I changed the comments from # to echo #.

Also unfortunately empty lines are not accepted (i changed them to "echo &")

The result is ugly but it works.
I hope this helps...

@CAMOBAP
Copy link
Author

CAMOBAP commented Nov 20, 2020

Thanks @drdanz , BTW maybe you have some plan to allow configure she'll also?

P.S. this can be useful for *nix also because python she'll available there

@nick-invision
Copy link
Collaborator

@drdanz @CAMOBAP Could I get a few specific examples where multiline is not working as expected?

I'm testing this now using the following and not able to reproduce the issue:

      - name: Multiline, multi command
        uses: ./
        with:
          timeout_minutes: 1
          max_attempts: 1
          command: |
            echo "abc"
            echo "123"
      - name: Multiline single command
        uses: ./
        with:
          timeout_minutes: 1
          max_attempts: 1
          command: >-
            echo "abc 
            123"

Multiline, multi command outputs:

abc
123

Multiline single command outputs:

abc  123

I believe this to be correct because GitHub syntax for multiline commands begin with | and treat each newline as a separate command, and yaml syntax treats commands beginning with >- as a single string/command with newlines stripped and replaced by spaces.

@CAMOBAP
Copy link
Author

CAMOBAP commented Jan 4, 2021

@nick-invision thanks for the update, if it work now probably the issue wasn't related to this action. My example was as simple as yours, so I think we can close this one

P.S. Any plans to add support for different 'shell'?

@nick-invision
Copy link
Collaborator

nick-invision commented Jan 4, 2021

Alternate shell support has been added to v2. 3.0. See Readme or related issue #28 comments for examples.

@CAMOBAP
Copy link
Author

CAMOBAP commented Jan 4, 2021

@nick-invision awesome, thanks for the comment

@CAMOBAP CAMOBAP closed this as completed Jan 4, 2021
@kr99
Copy link

kr99 commented Jun 10, 2021

Can you add this as an example in the documentation? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants