Skip to content

Instantly share code, notes, and snippets.

@medwig
Created April 23, 2019 13:29
Show Gist options
  • Save medwig/de8f0fbd071e88feaa38e75e8cf87a5b to your computer and use it in GitHub Desktop.
Save medwig/de8f0fbd071e88feaa38e75e8cf87a5b to your computer and use it in GitHub Desktop.
Repair symlinks in AWS codepipeline
@skylarmb
Copy link

skylarmb commented May 9, 2025

years later, this is still a super helpful gist!

In my case I had many yml files in folders with various levels of nesting that all needed to be symlinked. I ran into issues using glob patterns so i switched it out for find:

  pre_build:
    commands:
      # Hack to fix the symlinks that Codepipeline breaks when it clones the repo
      # Applies to .yml files that contain only 1 line (a broken symlink)
      - >
        symlink_files=$(find ./my-folder -name "*.yml" -type f);
        for file in $symlink_files; do
          if awk "NR==2{exit}END{exit NR!=1}" "$file"; then
            content=$(cat "$file")
            ln -sf "$content" "$file"
            echo "Created symlink for $file -> $content"
          fi
        done;

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