How to try again if get resource is fail

Hello everyone!

Could anyone help me to find an approach to add attempts to restart get resource step if it failed to download a resource?

We use as a resource git://git.postgresql.org/git/postgresql.git to trigger if they deploy a new release, but for downloading release file we use their ftp - https://ftp.postgresql.org/pub/source/v__version__/postgresql-version.tar.gz

What is a problem
Sometimes they created a new release faster than upload file to ftp, as a result, build failed because it can’t download a file and we need to restart it manually. So is there any possibility to catch this situation and say to try 10 times with interval 1 hour between tries?

for example, how it can be in Jenkins:

Thank you

This can be done by using attempts: and on_failure: with a task that sleeps:

plan:
- get: postgres-ftp
  attempts: 10
  on_failure:
    task: sleep
    config:
      platform: linux

      image_resource:
        type: registry-image
        source: {repository: alpine}

      run: {path: sleep, args: ["3600"]}

It’d be nice if you didn’t have to do that though, and instead there was some way to have inter-dependent resources for situations like this where you can’t really change how the external assets are published. :thinking:

If such a feature existed we could avoid triggering the build in the first place until there are corresponding versions in both locations. I’m not really sure what a good syntax for this would be but I know I’ve run into similar situations in the past.

1 Like

Thank you. I will try your suggestion :slight_smile: