Can't reference a freestyle step’s working_directory from another step?


I’m setting up GitOps deployments following the official documentation

I’m wondering why the commit_and_push step’s working_directory isn’t referencing the previous change_manifest step’s working directory (instead the path is provided explicitly, which I’d like to avoid for DRY.

I’m sure there’s a good reason for that, because I tried to use working_directory: ${{change_manifest}} in the commit_and_push step and it fails :

Executing command: cd ${WORKING_DIRECTORY}                                                                                               
/bin/sh: 2: cd: can't cd to ${{change_manifest}}

Can’t a git-commit step reference a freestyle step’s working_directory ? I thought that was available for all types of steps.

Related question : how do you typically set this up for DRY with multiple environments ? I’d like to avoid just duplicating the steps with a different when/branch/only + different manifest path.

The problem is that the commit_and_push step is a typed step (custom plugin) and not a standard freestyle step. Custom plugins know nothing about git clones or previous steps in the pipeline. They are mostly self-contained (as far as defaults go).

You can see some more limitations here Steps · Codefresh | Docs

To solve your issue, if you don’t want to hardcode the path, I think you can use an environment variable for it (with cf_export).