0

I have a docker compose file with a windows container service. The command section takes a multiline batch command.

command:>     
 cmd /c "
      if "%build%"=="release" (
      cd some_dir ) else (cd other_dir) &&
      7z.exe a some_z * &&
      last_command & exit 0 "

with the if statement the multiline batch command always fails. Does anyone know why ? Thanks.

Omid
  • 57
  • 7
  • Please copy/paste to avoid typos. Batch can be sensitive to layout. `"build"` will never be equal to `"release"` You probaly need `%build%` (the *contents* of the variable `build`). Whether it's expressed that way in Dorker, I've no idea. – Magoo Feb 10 '23 at 10:44
  • can you try the if statement with just a single quotes. `if 'build'=='release'` – Mohammed Chaaraoui Feb 10 '23 at 11:14
  • Do `some_dir` and `other_dir` exist? What is the current directory? – Mike Mozhaev Feb 10 '23 at 21:49
  • Yes for sure because I manually copied them in. I was just wondering if this was a known issue and you can chain an if statement in batch. – Omid Feb 10 '23 at 22:57
  • The statement itself is good. You can try to replace `cd` commands with `echo` and see if it goes inside `if` statement. I can only imagine that the directories are not found so `if` statement fails and hence && doesn't go further. – Mike Mozhaev Feb 12 '23 at 09:30

0 Answers0