Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Ability to pass in arguments to the chocolateyinstall.ps1 file #133

Closed
micahlmartin opened this issue Jul 27, 2012 · 14 comments
Closed

Ability to pass in arguments to the chocolateyinstall.ps1 file #133

micahlmartin opened this issue Jul 27, 2012 · 14 comments

Comments

@micahlmartin
Copy link
Contributor

I'm using chocolatey to install our custom internal applications. I want the ability to pass in arguments that are accessible to the chocolateyinstall.ps1 file. I could solve some of it by setting some environment variables, but it would be easier if I could pass in the arguments to the installer. Essentially what I'd like to do is this:

cinst myapp -args @{arg1="value1";arg2="value2"}

Then from my chocolateyinstall.ps1 file I'd like to access them like this:

$args.GetEnumerator() | { 
     #Do something with my arguments
}

Currently the installArguments is automatically appended to the exe or msi arguments but I can't parse them or do anything with them from the chocolateyinstall.ps1 file

Link to original discussion: https://groups.google.com/group/chocolatey/browse_thread/thread/19160bee38885b97?hl=en

@ferventcoder
Copy link
Contributor

As much as possible I would like to avoid something powershell from the command line. The inner guts of chocolatey are powershell, but the way folks use it from the outside doesn't have to be.

@micahlmartin
Copy link
Contributor Author

It doesn't have to be powershell-y. Is there a way to access the installArguments? I could pass it a format that's easy to parse and use it that way.

cinst myapp -installArguments "key:1;key2:3" as an example. But how can I access that within chocolateyinstall.ps1?

@ferventcoder
Copy link
Contributor

Ha! I actually typed out the word "powershell-y" but then removed it. :D

You can access that within the ps1 (it's gets set as an environment variable), but are you worried about it moving on to the installer?

@ferventcoder
Copy link
Contributor

@micahlmartin
Copy link
Contributor Author

No, I'm not worried about the installer because I'm installing a zip file (which I don't think uses the arguments??). There's some customizations I want to do like pass in like where to install and what url to download it from.

@micahlmartin
Copy link
Contributor Author

So it sounds like the installArguments will solve my problem since I can access it like $env:chocolateyInstallOverride right?

@ferventcoder
Copy link
Contributor

$env:chocolateyInstallArguments

Do you think this might be better as an addition to https://github.com/chocolatey/chocolatey/blob/master/src/helpers/functions/Install-ChocolateyZipPackage.ps1

@ferventcoder
Copy link
Contributor

Like we'd leave it as installarguments but allow the settings to override defaults in chocolatey zip package function?

@micahlmartin
Copy link
Contributor Author

I'm not sure it would be that useful for 99% of cases. I'm using it to install our applications in a QA environment as well as production and depending on where I'm installing it I want to download the artifacts from different places and also want to tell it which version of the configs to use. It may be too much of an edge-case to change the way the zip installer works for everyone.

@micahlmartin
Copy link
Contributor Author

Another thing I need to do is pass in username and password so I can download the file using basic authentication. Currently the installer doesn't support this at all. Would be nice if it did. Perhaps I should create a separate issue?

@derekmurawsky
Copy link

I, too, would like to see the ability to do package-specific arguments or overrides. I'm building a package now that installs a SQL maintenance script and would love to provide variables for configuration. For example, which instance the script should install to.

@ferventcoder
Copy link
Contributor

I'm closing this as a dupe of #159 - that's where the work was done. Use -params

@alyssenko-ssi
Copy link

So did this '$env:chocolateyInstallArguments' functionality ever get implemented? I need to be able to modify the $zabbixConf variable inside the chocolateyInstall.ps1 script for zabbix-agent install- not seeing how this is currently possible?

@ferventcoder
Copy link
Contributor

@alyssenko-ssi An environment variable for Install Arguments was implemented. However it should not be looked at all for packages. If you need information from the user, one should be using $env:chocolateyPackageParameters, see #159.

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

No branches or pull requests

4 participants