Using graphviz in gitlab

I am trying to visualize how different projects depend on one another. I think a good way to do this is to send a survey around to some project developers asking about what their inputs and outputs are and map the results with graphviz. Once most of the “skeleton” of my graph is in place, I’d like to open the survey up to project teams for them to expand and correct. Because I anticipate many more responses from this second circulation, I think the easiest way to stay on top of it is to have people pull a git repo, edit a file with a list of nodes, and then push the repo back. At that point, gitlab will run a script redrawing the network from the user’s changes. This all goes well in my test case until I need to save a png image of the map, at which point I get the error graphviz.backend.execute.ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH

I solved this locally by brew installing graphviz, rather than using pip, but brew isn’t recognized on the gitlab setup I must use. Any ides how to get around this?

I believe that you (only) installed the python linterface (named graphviz), but not the actual graphviz package (see Download | Graphviz)

For more info:

I did get this working. For the curious, here is what my yml file looks like:

stages:
  - generate

create_pdf:
  stage: generate
  image: python
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
      changes:
        - input.ini
  script:
    - apt-get update -qy
    - apt-get install -y graphviz
    - pip install -r requirements.txt. # just one line reading "graphviz==0.21"
    - python generate_map.py
    - mkdir -p public
    - cp map_1.pdf public/map_1.pdf
    - cp map_2.pdf public/map_2.pdf
    - cp dependency_issues.log public/logfile.log
    - git config --global user.email "ci-bot@example.com"
    - git config --global user.name "CI Bot"
    - git remote set-url origin https://oauth2:${GIT_PUSH_TOKEN}@gitlab.org/${CI_PROJECT_PATH}.git
    - git add public/*.pdf
    - git add public/*.log
    - git commit -m "Map update" || echo "No changes to commit"
    - git push origin HEAD:main
  artifacts:
    paths:
      - map_1.pdf
      - map_2.pdf
      - logfile.log
    expire_in: 1 week
1 Like