Export raw log from Git clone step for subsequent steps

It would be awesome if Git clone could export also the raw logs into a file and put the filename into an environment variable.

My use case is I have a subsequent script step that, if the git clone fails, posts an informative message into Slack for whoever triggered the build. I would like to distinguish between things like “there was a merge conflict,” or “the branch that you tried to built was deleted” etc. Right now, all I have to go on is the exit code of the git clone step which is always 1.

Hey @grailed thanks for posting your question and welcome to the community!

While our current git clone step doesnt have this capability, you can use a Script Step to export the raw log into a file and set the file’s name as an Environment Variable (Env Var).
First, you need to create a Script Step and add the following code to it:


# Export the raw log into a file

git clone <repository_url> <destination_directory>

# Set the file's name as an Environment Variable

envman add --key <ENV_VAR_KEY> --value <FILE_NAME>

If you want to expose the value of an Env Var to be accessible through the key of another Env Var, you can do so. For example, to expose the value of BITRISE_BUILD_NUMBER under the key MY_RELEASE_NOTE, you can add the following code to your Script Step:

envman add --key MY_RELEASE_NOTE --value "$BITRISE_BUILD_NUMBER"

You can then use the MY_RELEASE_NOTE Env Var in other Steps, such as the Slack Step, to access the value of BITRISE_BUILD_NUMBER.

Please let me know if this was helpful or if you need any further assistance.


Thank you Leilah. Yes, I’m aware that’s an option :slight_smile:

I just think it would be nice to have it built-in to the step.

Ha ha fair enough! Just looking to help out with possible work arounds :wink: