This message was deleted.
# community-support
s
This message was deleted.
e
Though you will not be able to reference the
gradleEnterprise
extension like that.
Something like this might work.
d
I’ve been using this set up for people to put into their init.d
Copy code
if (gradle.getParent() == null) {
  beforeSettings { settings ->
    settings.buildscript.repositories { gradlePluginPortal() }
    settings.buildscript.dependencies.add("classpath", "com.gradle:gradle-enterprise-gradle-plugin:3.10")
    settings.buildscript.dependencies.add("classpath", "com.gradle:common-custom-user-data-gradle-plugin:1.6.5")
  }
  settingsEvaluated { settings ->
    settings.buildCache {
      local {
        enabled = true
      }
      remote(HttpBuildCache) {
        url = '<https://your.gradle.enterprise.server/cache/>'
        enabled = true
      }
    }
    if (!settings.pluginManager.hasPlugin("com.gradle.enterprise")) {
      settings.pluginManager.apply("com.gradle.enterprise")
    }
    if (!settings.pluginManager.hasPlugin("com.gradle.common-custom-user-data-gradle-plugin")) {
      settings.pluginManager.apply("com.gradle.common-custom-user-data-gradle-plugin")
    }
    settings.extensions["gradleEnterprise"].with {
      server = "<https://your.gradle.enterprise.server/>"
      buildScan {
        publishAlways()
        capture {
          taskInputFiles = true
        }
        uploadInBackground = System.getenv('GO_SERVER_URL') != null || System.getenv('GITLAB_CI') != null
      }
    }
  }
}
We’re on groovy syntax, you’d need to swap it out for Kotlin if that’s what you’re using. We opted to not use kotlin in the init script as the compile time for that was incredibly slow compared to Groovy.
n
@Ivan CLOVIS Canet @Daniel B Duval here are examples on how to configure publishing in the Groovy syntax for both scans.gradle.com as well as your own Gradle Enterprise server from an init script: https://docs.gradle.com/enterprise/gradle-plugin/#many-projects
i
@Eric Haag It almost seems to work, but I get
Copy code
* What went wrong:
Extension of type 'GradleEnterpriseExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension, GradleEnterpriseExtension, RefreshVersionsExtension]
@no this seems to work, however it's setting up the enterprise server URL rather than the build scan ToS
n
can you try the sample for
<http://scans.gradle.com|scans.gradle.com>
?
it is beneath the Gradle Enterprise sample
i
@no it does work, thanks! However, it prints
Copy code
An internal error occurred that prevented a build scan from being created.
Please report this via <https://github.com/gradle/gradle/issues>
with no further information.
(the build scan is actually created, and looks normal at first glance)
n
can you share the build scan link?
are you able to share the project's code?
i
The project is https://gitlab.com/opensavvy/formulaide, I just ran
./gradlew clean --scan
on the
main
branch
n
i see. do you use
--scan
in combination with the init script?
i
Yes, I added the second example you gave verbatim to the user home init script, then ran the above command
n
If you omit
--scan
does it still give you the internal error?
i
With
--scan
there is no error (but of course, it doesn't generate the scan)
n
I see. If you add
publishAlways()
inside the
buildScan
block in the init script and run without
--scan
, does it give the error?
i
No error, and it does generate the build scan 🤔
n
thanks. that should help you out for now! i'll report the error internally
i
Thanks! If you create a GitHub issue/whatever, don't hesitate to send the link here so I can subscribe to it in case further information is necessary
n
I will link here if we create a public issue about this.
i
Small note, I was using the Kotlin DSL version of the build script, but it seems you managed to reproduce it with the Groovy DSL so I guess it's not relevant