Alright another one that wasted me too much time: the way dagu handles variable expansion in commands -or other parts- differ from the preconditions.
I couldn’t find any mention of this difference in the documentation, and I’m not sure whether it’s intentional.
Example DAG
This is a simple example dag that creates a file dagu-test.txt in the users home and echo 1 if the created file exists.
env:
TEST_FILE: ~/dagu-test.txt
steps:
- command: touch $TEST_FILE
- command: echo 1
preconditions:
- condition: test -f $TEST_FILE
Expected behaviour
The file dagu-test.txt is created in the users home and the second step echoes a 1.
Actual behaviour
The file is created but the second step is skipped with failed preconditon.
Reason
I've managed to track the issue to the way dagu is expanding the variable -or lack thereof- in the precondition.
The expansion of the variable is being handled differently in the precondition and the ~ is not being expanded. Instead the shell is looking for a literal ~. Replacing ~ with a path or variable works. eg TEST_FILE: $HOME/dagu-test.txt.
Alright another one that wasted me too much time: the way dagu handles variable expansion in commands -or other parts- differ from the preconditions.
I couldn’t find any mention of this difference in the documentation, and I’m not sure whether it’s intentional.
Example DAG
This is a simple example dag that creates a file dagu-test.txt in the users home and echo 1 if the created file exists.
Expected behaviour
The file dagu-test.txt is created in the users home and the second step echoes a 1.
Actual behaviour
The file is created but the second step is skipped with failed preconditon.
Reason
I've managed to track the issue to the way dagu is expanding the variable -or lack thereof- in the precondition.
The expansion of the variable is being handled differently in the precondition and the ~ is not being expanded. Instead the shell is looking for a literal ~. Replacing ~ with a path or variable works. eg
TEST_FILE: $HOME/dagu-test.txt.