Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

bitbucket-pipelines.yml - git command not found

ffmit July 1, 2018

Hello guys,

The problem is, when I push changes to Bitbucket and these are then pushed to Heroku the git command is not found.

  • Laravel PHP info app with phpinfo view, no extras
  • Bitbucket Cloud with Heroku pipeline
  • Heroku app accordingly configured

Please see my bitbucket-pipelines.yml in link to pastebin

When the pipeline step "Deploy to Heroku" runs, it aborts saying

git push
https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD

bash: git: command not found

In the build setup, the installation of git successfully finishes. Screenshot

Why does the git command afterwards fail?

 

Thanks in advance!

1 answer

2 votes
Jeroen De Raedt
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 18, 2018

Hey @ffmit,

this is most likely because the git client is not installed in the Docker image that you are using (php:7.1.3). 

You can either look for a different image that has git installed, or try installing it (e.g. through `apt-get install git-core` as the first command of your script). 

ffmit July 31, 2018

Hello @Jeroen De Raedt,

thanks for your reply, but it is not working, my pipeline is this:

 

 

# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.1.3

pipelines:
default:
- step:
name: Set up the docker container
caches:
- composer
script:
- apt-get update && apt-get install -y unzip git git-core libc-client-dev libkrb5-dev && rm -r /var/lib/apt/lists/*
- docker-php-ext-configure imap --with-kerberos --with-imap-ssl && docker-php-ext-install -j$(nproc) imap
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install
- vendor/bin/phpunit

- step:
# set HEROKU_API_KEY and HEROKU_APP_NAME environment variables
# set clone `depth: full' as described here: https://confluence.atlassian.com/x/Y9-5Mw
name: Deploy to Heroku
deployment: test # set to test, staging or production
# trigger: manual # uncomment to have a manual step
script:
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD

 


It still fails with: "+ git push https://heroku:$HEROKU_API_KEY@git.heroku.com/docster-test.git master
bash: git: command not found

Jeroen De Raedt
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 31, 2018

Hey @ffmit,

you installed git in your first step - whereas it is actually needed in your second step.

 

Try updating your second step to: 

- step:
# set HEROKU_API_KEY and HEROKU_APP_NAME environment variables
# set clone `depth: full' as described here: https://confluence.atlassian.com/x/Y9-5Mw
name: Deploy to Heroku
deployment: test # set to test, staging or production
# trigger: manual # uncomment to have a manual step
script:
- apt-get update && apt-get install -y unzip git git-core libc-client-dev libkrb5-dev && rm -r /var/lib/apt/lists/*
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD

Like DuLobo likes this
ffmit August 4, 2018

Hello @Jeroen De Raedt,

thanks a thousand times! Indeed, it was the problem that I thought that in the first step I do prepare the whole environment and that in the second step I use it.

Would be great if you could point me (and maybe others) into the right direction at the docs, where this is explained.

Have a nice day, thanks!

Kerstin_Schulze063 September 12, 2018

each step runs in an seperate docker container so you need to prepare it in the same step as you use it, on the other hand this makes it possible to run different steps with different docker images ^^ this was said in the summit 2016 video on youtube if i remember it rigth

Chris Habgood August 5, 2023

I am still getting git command is not found.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events