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

FAQ suggests getEnv instead of gradle provider #182

Open
xenoterracide opened this issue Jul 14, 2021 · 1 comment
Open

FAQ suggests getEnv instead of gradle provider #182

xenoterracide opened this issue Jul 14, 2021 · 1 comment

Comments

@xenoterracide
Copy link

xenoterracide commented Jul 14, 2021

this is a snippet of kotlin dsl I'm using for another plugin, I'm not sure on the groovy syntax, but this is how you should get a property. Sadly I don't fully understand it, but apparently, this is better.

  val isCI = providers.environmentVariable("CI").forUseAtConfigurationTime().isPresent
  ratchetFrom = if (isCI) "HEAD~1" else "HEAD"
@deepy
Copy link
Member

deepy commented Jul 14, 2021

Ooh, that's a neat feature from 6.1 that I'd missed, forUseAtConfigurationTime() makes everything safe for the configuration cache, so in general we should go for that.

For groovy I think you'd probably use .getOrNull() instead and rely on groovy's truthiness check (i.e. saving you from that moment when you set CI=false to test something without thinking it through)

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