tbrand / neph

A modern command line job processor, similar with make command
https://tbrand.github.io/neph/
MIT License
204 stars 7 forks source link

Defining env var from job #57

Closed waghanza closed 6 years ago

waghanza commented 6 years ago

Hi,

I'm working on https://github.com/tbrand/which_is_the_fastest and I have not expected result when running neph -> I'm on 0.1.21.

There is my config file

main:
  command:
    echo "The result is $CID"
  depends_on:
    -
      job: rails
      env: CID

rails:
  command: |
    sudo docker build -t rails .
    sudo docker run -td rails
  dir: ruby/rails

The expected result is tho show a container (docker) ID when running neph

Regards,

PS : I take inspiration from https://github.com/tbrand/neph/wiki/Set-a-job-result-to-env-vars

notramo commented 6 years ago

What is the current result?

waghanza commented 6 years ago

Nothing, the output is

Neph is running (0.1.21) ||||||||||||||||||||||||||||||||||||||||||||||||||100%
main [2/2] done.   2.39ms
 - rails [1/1] done.   1.44s

Finished in 1.5s
notramo commented 6 years ago

Neph don't redirects the output of jobs to the terminal, because it can run multiple jobs in parallel, and if each job prints to the terminal, it could mess up the output. It stores the stdout of the job in .neph/<job_name>/log/log.out, and the stderr in the same directory with the log.err name.

waghanza commented 6 years ago

:+1: However, I have

Step 1/7 : FROM ruby:2.4
 ---> c8614da568ef
Step 2/7 : RUN apt-get update     && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> fdbf37015e48
Step 3/7 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 49814a9ecf09
Step 4/7 : COPY Gemfile* ./
 ---> Using cache
 ---> b062a56911e0
Step 5/7 : RUN bundle install
 ---> Using cache
 ---> a4b908dfd530
Step 6/7 : COPY . .
 ---> Using cache
 ---> 34fabda8e405
Step 7/7 : CMD rails s -b 0.0.0.0 -e production
 ---> Using cache
 ---> 430464c562df
Successfully built 430464c562df
415fe87db28a8066f4cd47e6883e865a16262da7b3bacb377bc453c88ab6fe2b

The id 415fe87db28a8066f4cd47e6883e865a16262da7b3bacb377bc453c88ab6fe2b is what I expect (only this), but I can find in .neph/rails/log/log.out the output of subcommands :stuck_out_tongue:

notramo commented 6 years ago

If you run the commands of the rails job in the terminal (both commands), is the ID the only output?

waghanza commented 6 years ago

you're right :stuck_out_tongue: it is the output of both command ;-)

waghanza commented 6 years ago

so, this configuration is OK

main:
  depends_on:
    - rails

rails:
  command: |
    sudo docker build -t rails . &>/dev/null
    sudo docker run -td rails
  dir: ruby/rails

thanks