I'm trying to send variable to image in services, bit it seems like the variable is not being accepted and it throws error in the line where image with variable is defined.
Please find the yaml file below
image: image:latest definitions: steps: - step: &udpateEnvVariable name: Populate Environment script: - export ENV=dev - if [ "$FRONTEND_IMAGE" = "release" ]; then export ENV=qa; elif [ "$FRONTEND_IMAGE" = "daily" ]; then export ENV=dev; else export ENV=dev; fi services: frontend: image: name: image_name:$IMAGE options: docker: true pipelines: custom: dummy: - variables: - name: IMAGE default: daily allowed-values: - daily - release - misc - step: *udpateEnvVariable - step: name: Dummy services: - frontend script: - echo "ENV is $ENV"
and below is the error thrown
I don't think that the YAML above is valid at all. Validate this with an online validator before anything else.
YAML is very sensitive to indentation and line-breaks, those have important meaning.
I couldn't paste the code in yaml format, but to make it simple, i'm trying to provide service value as a variable, something like
definitions:
services:
frontend:
image:
name: $docker_image
OR
services:
- $docker_image
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The variable in this case is a regular Bitbucket pipeline variable?
Also, I don't know, but I guess it is rather likely that variable names are case-sensitive.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Mohan Kona ,
Just adding to @Aron Gombas _Midori_ response, using variables to define image names and services is not yet possible directly in the YAML file.
However, Bitbucket Cloud has recently launched a new feature called Dynamic Pipelines. This feature is designed to make every part of the Pipeline workflow easy to customize and adjust with parameters/variables.
With Dynamic Pipelines, you can use Variable and Deployment APIs to add any custom variables you need at any point in the Pipeline.
You can find more information on how to use these APIs here: Atlassian Community Link.
Thank you, @Mohan Kona !
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.