Skip to content

pipeline: make ruby version dynamic in buildspec #4446

Open
@fade2black

Description

My goal is to use Ruby 3.1.2 (since my RoR app uses 3.1.2), so I specify an image inside the pipeline manifest file like this

...
build:
  image: aws/codebuild/amazonlinux2-x86_64-standard:4.0
...

When I start build it fails with the following error:

...
Running command pipeline=$(cat $CODEBUILD_SRC_DIR/copilot/pipelines/liquandum/manifest.yml \| ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))')
--
/root/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych/class_loader.rb:99:in `find': Tried to load unspecified class: Date (Psych::DisallowedClass)
...

which is caused by parsing manifest file inside the buildspec.yml. It is a ruby script.
The following fixes it:

- pipeline=$(cat $CODEBUILD_SRC_DIR/copilot/pipelines/liquandum/manifest.yml | ruby -ryaml -rjson -e 'require "date"; puts JSON.pretty_generate(YAML.load(ARGF, permitted_classes:[Date]))')

We simply need to require "date" and pass the class Date inside the permitted_classes array.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area/pipelineIssues about pipelines to release applications.type/enhancementIssues that are improvements for existing features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions