Praqma/JenkinsAsCodeReference

munchausen fails: wrong output from generate-compose.py

Closed this issue · 0 comments

Took me a while to find the root cause of why our jenkins-as-a-code_pipeline did not redeploy the master. Here's my proposed fix!
Turns out that the generate-compose.py outputs an incorrect docker-compose.yml

Expected:

...
volumes:
    - /var/lib/docker:/var/lib/docker
    - /var/run/docker.sock:/var/run/docker.sock
    - /etc/localtime:/etc/localtime
...

Actual:

...
volumes:
    - "'[/var/lib/docker:/var/lib/docker'
    - /var/run/docker.sock:/var/run/docker.sock
    - /etc/localtime:/etc/localtime]"
...

The reason:
"docker inspect" output is wrapped with quotes which we don't escape, which confuses the yaml exporter

The fix:
In generate-compose, replace all strip('[|]') with strip('"[|]') to also remove the quotes