image: dchevell/docker-release-maker:latest
clone:
  depth: full

pipelines:
  custom:
    create-release-base-5:
      - step:
          script:
            - git remote set-url origin ${BITBUCKET_GIT_HTTP_ORIGIN}
            - git fetch --all
            - export BASE_BRANCH='base-5'
            - export MAC_PRODUCT_KEY='bitbucket'
            - export DOCKERFILE_VERSION_STRING='BITBUCKET_VERSION'
            - export DEFAULT_RELEASE='true'
            - export ADDITIONAL_TAG_SUFFIXES='alpine'
            - python /usr/src/app/run.py --create
    create-release-base-6:
      - step:
          script:
            - git remote set-url origin ${BITBUCKET_GIT_HTTP_ORIGIN}
            - git fetch --all
            - export BASE_BRANCH='base-6'
            - export MAC_PRODUCT_KEY='bitbucket'
            - export DOCKERFILE_VERSION_STRING='BITBUCKET_VERSION'
            - export DEFAULT_RELEASE='true'
            - export ADDITIONAL_TAG_SUFFIXES='jdk8,ubuntu'
            - python /usr/src/app/run.py --create
    test:
      - step:
          image: docker:stable-git
          script:
            # Run bitbucket docker image
            - mkdir -p data
            - |
                docker run -v $(pwd)/data:/var/atlassian/application-data/bitbucket \
                  --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket-server
            # Run tests
            - git show origin/scripts:scripts/test-bitbucket-status.sh | install -m 0755 /dev/fd/0 test-bitbucket-status.sh
            - ./test-bitbucket-status.sh
          services:
            - docker

  branches:
    base-5:
      - step:
          script:
            - git remote set-url origin ${BITBUCKET_GIT_HTTP_ORIGIN}
            - git fetch --all
            - export BASE_BRANCH='base-5'
            - export MAC_PRODUCT_KEY='bitbucket'
            - export DOCKERFILE_VERSION_STRING='BITBUCKET_VERSION'
            - export DEFAULT_RELEASE='true'
            - export ADDITIONAL_TAG_SUFFIXES='alpine'
            - python /usr/src/app/run.py --update
    base-6:
      - step:
          script:
            - git remote set-url origin ${BITBUCKET_GIT_HTTP_ORIGIN}
            - git fetch --all
            - export BASE_BRANCH='base-6'
            - export MAC_PRODUCT_KEY='bitbucket'
            - export DOCKERFILE_VERSION_STRING='BITBUCKET_VERSION'
            - export DEFAULT_RELEASE='true'
            - export ADDITIONAL_TAG_SUFFIXES='jdk8,ubuntu'
            - python /usr/src/app/run.py --update