Allow setting custom dest of get_url when using download deployment strategy
There is some cases where the URL does not contain the filename, therefore the auto-generated name is not suitable.
For example, downloading artifacts from Gitlab API is done using the following URL
https://<gitlab-on-premise-url>/api/<version>/projects/<project_id>/jobs/artifacts/<branch>/download?job=<job-name>
Therefore the downloaded file will have the name download?job=<job-name>.
Having a new variable like ansistrano_download_dest to manually set the destination file name would be awesome!
First of all, the downloaded file will (or at least, should) be called download, stripping out the query string.
And anyway, why is the auto-generated name relevant? If you are using the combined "download_unarchive" it does not matter what the filename is as it will be unarchived and deleted and if that is not the case, you need to treat the file anyway with some hook so if you could specify what's the use case where this is relevant that would be appreciated
I confirm that the file name contains the query string, which is unexpected.
I did not explored the download_unarchive yet, i'll check this, looks like it's what I need!
I don't have in mind a specific case where the file name is very important, but I can imagine some cases where keeping the downloaded file in the release folder could be helpful, and in that case it's better if it has a good name.
I know it can be achieved by custom hooks.
You can close this issues if you find it irrelevant.
Anyway, thanks for your help!
This is weird, we added some ansible filters to prevent the files having the query string when downloaded
Would it be possible to share the exact url you are downloading from (obv taking out any tokens or similar things that may affect security)?
{{ ansistrano_get_url | urlsplit('path') | basename }} should do the trick to, at least, strip out the query string
The URL is
# deploy_environment is either prod or staging
ansistrano_get_url: "https://<gitlab-on-premise-domain>/api/v4/projects/524/jobs/artifacts/{{ ansistrano_git_branch }}/download?job=build:{{ deploy_environment }}"
For staging, the file name is download?job=build:staging

Maybe injecting a variable in the query string part of get_url could cause this behavior ?