Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting custom dest of get_url when using download deployment strategy #384

Open
sylvain1811 opened this issue Apr 12, 2022 · 4 comments

Comments

@sylvain1811
Copy link

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!

@ricardclau
Copy link
Member

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

@sylvain1811
Copy link
Author

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!

@ricardclau
Copy link
Member

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

@sylvain1811
Copy link
Author

sylvain1811 commented Apr 13, 2022

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

image

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants