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

How can I set variable ( and pass to another task ) based on command output? #342

Closed
lukasmrtvy opened this issue Jun 10, 2020 · 2 comments
Labels
state: duplicate Duplicates another issue.

Comments

@lukasmrtvy
Copy link

How can I set variable ( and pass to another task ) based on command output?
For example:

version: '3'

tasks:
  main:
    cmds:
      - task: notify:post
      - task: dosomething
      - task: notfy:update
  dosomething:
    cmds:
       - mycommand # should set STATUS variable
  notify:post:
    cmds:
      - curl -X POST -d  '{"name":"foobar","status":"new"}' https://api/post | jq '.responseID' # should set RESPONSEID
  notify:update:
    cmds:
      - curl -X POST -d '{"id":"{{ .RESPONSEID}}","body":"{{ .STATUS }}"}' https://api/update

Thanks

@fairbairn
Copy link

Similar question, I'm trying to figure out how to capture the $? exit code value from a prior command, and then use that var in other commands...it appears it gets absorbed.

Is there a global var that gets assigned to the context as each step is executed?

I want to know if a prior command worked so downstream commands can determine what to do.

cmds:
    - cmd: exit 1
      ignore_error: true
    - work=$?
    - echo $work

@andreynering andreynering added the state: duplicate Duplicates another issue. label Jun 13, 2020
@andreynering
Copy link
Member

Hi @lukasmrtvy and @fairbairn,

I'm closing this issue as a duplicate of #178, but feel free to add more opinions there about how you see this working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: duplicate Duplicates another issue.
Projects
None yet
Development

No branches or pull requests

3 participants