Praqma / JenkinsAsCodeReference

This repository is intended for the reference Jenkins configuration as code as well as JobDSL library
BSD 3-Clause "New" or "Revised" License
142 stars 110 forks source link

munchausen fails: wrong output from generate-compose.py #208

Closed robinerd closed 6 years ago

robinerd commented 6 years ago

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