pipeline builds fail with: sh: git: not found

phazerphoo November 25, 2016

hello,

see the included log of our pipelinebuilds :

+ docker run -t --entrypoint=/bin/bash --memory=4096m -e BUILD_DIR=/opt/atlassian/pipelines/agent/build -v /tmp/bashScript4949262805177817574.sh:/tmp/bashScript4949262805177817574.sh:ro -v build-volume-d4a7b51d-4eb4-4e51-a382-512b8df1acde:/opt/atlassian/pipelines:rw -w /opt/atlassian/pipelines/agent/build --label com.atlassian.pipelines.agent="a983833ab610" "atlassian/pipelines-dvcstools:latest" -i /tmp/bashScript4949262805177817574.sh
WARNING: Your kernel does not support swap limit capabilities, memory limited without swap.
+ umask 000
Completed at 2016-11-25T14:26:11Z
+ git clone --branch="develop" --depth 50 https://x-token-auth:$AUTH_TOKEN@bitbucket.org/MYCOMPANYREPO/api-b2b.git $BUILD_DIR && git reset --hard f1a3a7263995feba8cef88af8c8a04dc2bbda1ec && git remote set-url origin https://x-token-auth:{access_token}@bitbucket.org/MYCOMPANYREPO/api-b2b.git
Cloning into '/opt/atlassian/pipelines/agent/build'...
remote: Counting objects: 3801, done.[K
remote: Compressing objects:   0% (1/2962)   [K
....
Resolving deltas: 100% (833/833), done.
Checking connectivity... done.
HEAD is now at f1a3a72 bitbucket-pipelines.yml edited online with Bitbucket
Completed at 2016-11-25T14:26:14Z
+ chmod 777 $BUILD_DIR
Completed at 2016-11-25T14:26:14Z
+ docker pull "codacy/codacy-phpmd:latest"
latest: Pulling from codacy/codacy-phpmd
...
a3ed95caeb02: Already exists
Digest: sha256:5106c29fd0821e9506bdd02c57a287f88996428542d340ae1279bcb6b148c137
Status: Image is up to date for codacy/codacy-phpmd:latest
+ docker run -t --rm=true --cidfile=/tmp/1480083970733-0/{5ef5fb22-9613-4a43-828a-df5e6135b9a4} --entrypoint=/bin/bash --memory=4096m --env-file=/tmp/dockerEnvironment863254565942487817.env -v /tmp/bashScript7637037326496481896.sh:/tmp/bashScript7637037326496481896.sh:ro -v build-volume-d4a7b51d-4eb4-4e51-a382-512b8df1acde:/opt/atlassian/pipelines:rw -v build-volume-d4a7b51d-4eb4-4e51-a382-512b8df1acde:/opt/atlassian/bitbucketci:rw -w /opt/atlassian/pipelines/agent/build --label com.atlassian.pipelines.agent="a983833ab610" "codacy/codacy-phpmd:latest" -i /tmp/bashScript7637037326496481896.sh
WARNING: Your kernel does not support swap limit capabilities, memory limited without swap.
+ composer install --ignore-platform-reqs --prefer-dist
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
  - Installing bshaffer/oauth2-server-php (v1.8.0)
    Downloading: Connecting...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%
......
  - Installing zendframework/zend-barcode (2.6.0)
    Downloading: Connecting...    Downloading: 0%               Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 30%    Downloading: 35%    Downloading: 45%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 80%    Downloading: 90%    Downloading: 95%    Downloading: 100%
  - Installing zendframework/zend-authentication (2.5.3)
    Downloading: Connecting...    Downloading: 0%               Downloading: 10%    Downloading: 20%    Downloading: 30%    Downloading: 40%    Downloading: 50%    Downloading: 55%    Downloading: 65%    Downloading: 75%    Downloading: 80%    Downloading: 90%    Downloading: 100%
  - Installing zendframework/zendframework (2.5.3)
    Downloading: Connecting...    Downloading: 0%               Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 45%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%
    Skipped installation of bin bin/templatemap_generator.php for package zendframework/zendframework: name conflicts with an existing file
  - Installing MYCOMPANYREPO/cache (dev-develop baefb3e)
    Cloning baefb3ed9511b676981bf8727b6ff15f8d4b94c9
                                                                                                                         
  [RuntimeException]                                                                                                     
  Failed to clone git@bitbucket.org:MYCOMPANYREPO/cache.git, git was not found, check that it is installed and in your PATH env.  
  sh: git: not found                                                                                                     
                                                                                                                         
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...

 

here is the pipeline yaml:

 

# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/VYk8Lw 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: sideci/ubuntu14.04-php-phpmd:latest

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - composer install --ignore-platform-reqs --prefer-dist
          - phpmd vendor/mgis,module html codesize,cleancode,unusedcode

 

any idea why it keeps crashing? 

 

 

3 answers

1 accepted

2 votes
Answer accepted
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 27, 2016

My guess is that the docker images you're using don't have git installed. It looks like composer is trying to download dependencies using git, so you'll need to find or build your own docker image that includes git as well as all the other dependencies your project needs. I don't know anything about composer or php, but perhaps a specialised composer image would be suitable? https://hub.docker.com/r/composer/composer/

If you can't find an image that has everything you need and you don't want to build your own image then another option is to use the best image you can find and then install the remaining dependencies in your pipeline script before running your other commands.

One other issue you may run into - if you need to clone private git repositories within your build script (eg. via composer) then you'll need to configure authentication. The recommended approach is using ssh keys, as described here: https://answers.atlassian.com/questions/39429257 and here: https://answers.atlassian.com/questions/39243415

phazerphoo November 28, 2016

hi steven, 

thanks for the reply. yeah, that was exactly the problem. i have just build me an docker image(https://hub.docker.com/r/herrmannhinz/ubuntu14-ci/) with git.
its working now flawless. until...
...now i'm running into the ssh key topic u where just pointing at. 

i am trying to solve this now.  thanks for the link to the possible solution. 

btw really like that you guys are integrating drone. 
 

phazerphoo November 28, 2016

works fine now. thanks. thumbs-up

now i would like to post some of the build process to hipchat. 
playing around with the HipChat api now.   

2 votes
Steffen Schlaer May 24, 2017

You also can add git command by installing via pipelines script.

Example of bitbucket-pipelines.yml for an PHP docker.

# 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.1

pipelines:
  default:
    - step:
        script:
          - apt-get update && apt-get install -y unzip git
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install
          - vendor/bin/phpunit
Jørgen Teunis January 16, 2018

 

apt-get update and apt-get install result in this error for me, always (no matter what image I use, debian-stable php.7.1.1 php-fpm):

Reading state information...

E: Unable to locate package

My question: https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-pipeline-apt-get-update-and-install/qaq-p/705340

0 votes
Erlang Parasu March 25, 2018

this sample working for me :)

image: php:7.1
clone:
depth: full
pipelines:
default:
- step:
script:
- php -v
- apt-get update
- apt-get install -y unzip git
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
Ndu Victor O. October 31, 2018

This was my solution..

apt-get install -y unzip git

adding this line saved the day

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events