Using custom Git commands
Manually clone Git repositories
Manually running Git commands is an advanced technique. For most use cases you should use the native Git checkout offered by Codefresh.
For complex cloning, you can still use custom clone commands in a freestyle step. In this case, you lose the native Codefresh integration such as Git authentication and automatic workdir setup. Use custom clone commands only as a last resort.
Cloning with the Git executable
It is very easy to run custom Git commands in a freestyle step. Pass any parameters to the Git clone step as you would pass them on your local workstation.
rm command before the clone step. This makes sure that every time the pipeline runs, the
git clone step is implemented in an empty directory. Otherwise the
git clone command will fail (Git will refuse to clone on an existing directory).
You can enter your own Git username/password or reuse the credentials from the Codefresh integration.
Manually running Git commands
Once you understand that you can manually run Git commands in Codefresh pipelines, it is easy to see that any Git workflow is possible.
Here is an example where an application is packaged in a Docker container, after merging
master to a specific branch.
If there are any errors with the merge, the pipeline fails automatically. Codefresh automatically stops any pipeline that shows an error in a step.
Other forms of cloning
There is nothing special about running Git it in a freestyle step. In fact, you can check out code with any other command that you would run locally in your terminal.
Here is an example with Golang.
If you run this pipeline you will see git used as part of the
go get mechanism.
For more examples, such as using SSH keys and working with Git submodules, see the Git-clone step.