Shippable / support

Shippable SaaS customers can report issues and feature requests in this repository
101 stars 28 forks source link

Matrix build with tag dependent on language version #3658

Closed bbrala closed 7 years ago

bbrala commented 7 years ago

Im trying to get a matrix build going for PHP on a custom image. The tag should be based on the language version. I've tried quite a few things, bug cant seem to get it working as it should.

I would like to use

php:
  - "7.0"
  - "7.1"

and use that to set the image tag in the pre_ci_boot section. THe follwing works but id like to have the correct php version in the overview

env:
  global:
    # Hipchat config
    - PROJECT="Some project" 
  matrix:
    - IMAGE=php7.0
    - IMAGE=php7.1

pre_ci_boot:
    image_name: swisleiden/swisdev
    image_tag: ${IMAGE}

I also tried things as:

php:
  - "7.0"
  - "7.1"

env:
  global:
    # Hipchat config
    - PROJECT="Some project"
  matrix:
    - IMAGE=php7.0
    - IMAGE=php7.1

matrix:
  include:
    - php: "7.0"
      env: IMAGE=php7.0
    - php: "7.1"
      env: IMAGE=php7.1

pre_ci_boot:
    image_name: swisleiden/swisdev
    image_tag: ${IMAGE}

and a few different variations using matrix -> include. I also tried using image_tag: ${SHIPPABLE_PHP_VERSION} but it seems that variable is not available on the build host.

Can you point met in the right direction? I just want 2 builds on 2 different tags and have the correct PHP version in the interface :)

rageshkrishna commented 7 years ago

@bbrala On custom images, we do not automatically switch language versions for you because we don't know what's available in the image.

We make the language version from the YML available in an environment variable called SHIPPABLE_PHP_VERSION but it's up to you how to use that in your image to switch versions.

So the exact answer to your question really depends on how you've installed multiple PHP versions in your image. For example, we use phpenv to do this.

rageshkrishna commented 7 years ago

Oh, I misunderstood... you want the image tag to be based on the PHP version. Let me get back to you on this.

bbrala commented 7 years ago

:) cool thanks. Thing is i just dont get the correct filtered matrix to work.

rageshkrishna commented 7 years ago

OK, I think I have a way to unblock you but it's not pretty:

language: php

env:
  global:
    # Hipchat config
    - PROJECT="Some project"
  matrix:
    - IMAGE=php7.0
    - IMAGE=php7.1

matrix:
  exclude:
    - php: "5.6"
  include:
    - php: "7.0"
      env: IMAGE=php7.0
    - php: "7.1"
      env: IMAGE=php7.1

build:
  pre_ci:
    - echo $IMAGE
  pre_ci_boot:
    image_name: ragesh/foo
    image_tag: $IMAGE
  ci:
    - echo "Hello, world"

This gets you what you're looking for, but it's an elaborate workaround for the fact that we're not exporting the language version for the pre_ci_boot scripts. I'll add this to our backlog, but hopefully the YML above will help you until we fix this.

bbrala commented 7 years ago

Yeah that is pretty nasty :)

I think i rather wait for the implementation. Do you have a way to notify me when it is implemented? Perhaps add it to the userstory in your system?

rageshkrishna commented 7 years ago

Sure. We'll update this issue as soon as it's available.

rageshkrishna commented 7 years ago

Quick update -- we are planning to make this fix available before the end of the week.

rageshkrishna commented 7 years ago

@bbrala This now works as you would expect it to:

language: php
php:
  - "7.0"
  - "7.1"
build:
  pre_ci:
    - echo The PHP version is $SHIPPABLE_PHP_VERSION
    - docker tag drydock/u16phpall:master drydock/u16phpall:v$SHIPPABLE_PHP_VERSION
  pre_ci_boot:
    image_name: drydock/u16phpall
    image_tag: v$SHIPPABLE_PHP_VERSION
  ci:
    - echo "Hello, World!"

$SHIPPABLE_PHP_VERSION (and all of the other language-specific env variables) are now available for use in the pre_ci and pre_ci_boot sections of the YML.

bbrala commented 7 years ago

awesome, thanks. :)