Using Custom Git commands
Clone manually git repositories
Notice that running git commands manually is an advanced technique. For most use cases you should use the Native Git checkout offered by Codefresh.
If you want to do complex cloning, you can still use custom clone commands in a freestyle step. Notice however that 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 will run the
git clone step will happen 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.
Running Git commands manually
Once you understand that you can run manually 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 will automatically fail. Codefresh will automatically stop 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 checkout 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.
More examples such as using SSH keys and working with GIT submodules can be found in the clone step documentation.