Build an Image from a Different Git Repository

Using this repository we’ll help you figure out with properties of git-clone step.

Looking around

In the root of this repository you’ll find a file named codefresh.yml, this is our build descriptor and it describes the different steps that comprise our process. Let’s quickly review the contents of this file:


version: '1.0'
    type: git-clone
      username: ${{GITHUB_USERNAME}}
      password: ${{GITHUB_PASSWORD}}
    type: build
    working-directory: ${{clone_a_repo}}
    image-name: myuser/myservice
    tag: ${{CF_BRANCH}}

Just head over to the example repository in Github and follow the instructions there.

Using This Example

To use this example:

  • Fork this repository to your own [INSERT_SCM_SYSTEM (git, bitbucket)] account.
  • Log in to Codefresh using your [INSERT_SCM_SYSTEM (git, bitbucket)] account.
  • Click the Add Service button.
  • Select the forked repository.
  • Select the I have a Codefresh.yml file option.
  • Complete the wizard.
  • Rejoice!

Git-clone step with github token

How to generate the github token

Go to the page Personal access tokens Generate and configure the access for personal token Configuration in Codefresh:

We assume you already forked this repo and create a service for it

  1. Open the service and add new pipeline
  2. Switch to Use YML build
  3. Change the YML File Location to be ./codefresh.git.clone.example.yml
  4. Under Environment variables fill the next variables:
    • GIT_TOKEN your personal access token that you generated on GitHub
    • REPO_OWNER owner of repository that you want to clone
    • REPO_NAME name of repository that you want to clone
    • BRANCH branch of repo


    type: git-clone
    description: "Step description"
    repo: https://${{GIT_TOKEN}}${{REPO_OWNER}}/${{REPO_NAME}}.git
    revision: ${{BRANCH}}

Instead of hard-coding the credentials, you can provide the environment variables