My goal is to run some git command inside a build using Bamboo YAML spec and atlassian/bamboo-agent-base docker image.
This is the Dockerfile extended from atlassian/bamboo-agent-base (copied from https://hub.docker.com/r/atlassian/bamboo-agent-base)
FROM atlassian/bamboo-agent-base
USER root
RUN apt-get update && \
apt-get install maven -y && \
apt-get install git -y
The image is built as
atlassian-bamboo-extended:latest
Here is my bamboo yaml spec:
project:
key: COM
plan:
key: CSP
name: project CI
dockerImage: atlassian-bamboo-extended:latest
stages:
- jobs:
- scripts:
- '#!/bin/bash'
- echo starting push code task
- ls -la
- pwd
- git status
- git diff
- echo finished push code task
interpreter: shell
When the job runs, "ls -la" does list the source code. Here is the output of the rest of the command:
13-Feb-2019 23:22:29 error: object directory /var/bamboo/xml-data/build-dir/_git-repositories-cache/99b53e1f0d967effa88f7452e5067096c9acf7e1/.git/objects does not exist; check .git/objects/info/alternates.
13-Feb-2019 23:22:29 fatal: bad object HEAD
When the build is run without using the docker image, it works fine:
13-Feb-2019 23:25:07 On branch feature/SE-1234
13-Feb-2019 23:25:07 Your branch is up-to-date with 'origin/feature/SE-1234.
13-Feb-2019 23:25:07
13-Feb-2019 23:25:07 nothing to commit, working directory clean
Is there any reason why git does not work in the docker image?