Helmfile has a lot of errors in bitbucket-pipeline

carlos_mathiasen January 19, 2022

Hi guys, We have a problem with our pipeline.
We need to create a dynamic helmfile.yaml with a python script in pipeline, and use artifacts to pass to another step and run

helmfile apply 


If I run locally and manually all steps in the docker image, all works correctly, but in in bitbucket We always has a error with the yaml, our bitbucket-pipeline.yml:

tags:
  'v*':
    - step:
      name: "Prepare helmfile"
      image: python:3.7.2
      size: 2x
      script:
        - cd ./.infra
        - python myscript.py prd $BITBUCKET_BUILD_NUMBER
        - cp ../charts/helmfile.yaml ../helmfile.yaml
      services:
        - docker
      caches:
        - docker
      artifacts:
        - helmfile.yaml
    - step:
      name: "Release"
      trigger: manual
      script:
        - aws eks update-kubeconfig --region us-west-2
        - 'echo -e "\n - image_tag: $BITBUCKET_TAG" >> helmfile.yaml'
        - helmfile -e prod apply

we have errors like:

map has no entry for key "chart_repository"

or


in ./helmfile.yaml: failed to read helmfile.yaml: reading document at index 1: yaml: line 25: mapping values are not allowed in this context

If we do a cat helmfile.yml in the Release step, we can see the entire file and is Ok.


locally we run image:

docker run -it --rm -v $(pwd)/:/myapp myrepo.amazonaws.com/base:latest sh

and inside the container

python myscript.py prd $BITBUCKET_BUILD_NUMBER
helmfile -e prod apply

 and works perfectly.
What is wrong in the pipeline?

1 answer

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2022

@carlos_mathiasen  hi. Thanks for your question.
Maybe problem is with 

'echo -e "\n - image_tag: $BITBUCKET_TAG" >> helmfile.yaml'

added to your helmfile with wrong indentation.

Maybe try to use envsubst (your should have helmfile template and helmfile.yaml will be generated dynamically with each build):

envsubst < helmfile.tpl.yaml > helmfile.yaml


Please read this article:
https://github.com/roboll/helmfile/issues/429#issuecomment-455864318 

Additional links:
envsubst example , similar question 

Regards, Igor.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events