I have a Gradle build script which puts some artifacts in Artifactory. I am passing the Artifactory credentials as environment variables (windows only shop). Is there any way to control that certain enviromental variables DO NOT get published by the clientConfig.setIncludeEnvVars? Obviously, I want to hide those Artifactory credentials. I have tried some Ant-style exclude patterns, but it either doesn't work, or I have some syntax problem:
我有一个Gradle构建脚本,它在Artifactory中放置了一些工件。我将Artifactory凭据作为环境变量传递(仅限windows)。有没有办法控制某些环境变量不会被clientConfig.setIncludeEnvVars发布?显然,我想要隐藏那些Artifactory凭据。我尝试了一些Ant风格的排除模式,但它要么不起作用,要么我有一些语法问题:
clientConfig.setIncludeEnvVars(true, excludes: ['*PASS*'])
How the plugin is configured in the script:
如何在脚本中配置插件:
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'maven-~~~'
username = System.env.ARTIFACTORY_USER ? System.env.ARTIFACTORY_USER : ${artifactory_user}
password = System.env.ARTIFACTORY_PASS ? System.env.ARTIFACTORY_PASS : ${artifactory_password}
maven = true
defaults {
publications('mavenJava')
publishArtifacts = true
publishBuildInfo = true
publishPom = true
publishIvy = false
}
}
}
resolve {
repository {
repoKey = 'maven-d~~~'
username = System.env.ARTIFACTORY_USER ? System.env.ARTIFACTORY_USER : ${artifactory_user}
password = System.env.ARTIFACTORY_PASS ? System.env.ARTIFACTORY_PASS : ${artifactory_password}
maven = true
}
}
clientConfig.setIncludeEnvVars(false) // caution: true exposes passwords which are envs!
}
1 个解决方案
#1
2
clientConfig.setIncludeEnvVars()
accepts a boolean values and control whether to include the env vars as part of the build info.
clientConfig.setIncludeEnvVars()接受布尔值并控制是否包含env变量作为构建信息的一部分。
You should use either:
你应该使用:
clientConfig.setEnvVarsExcludePatterns('*password*,*secret*')
or
要么
clientConfig.setEnvVarsIncludePatterns('*not-secret*')
Both methods accepts a string which contains a comma delimited set of patterns. The patterns use star (*) as a wildcard.
两种方法都接受包含逗号分隔的模式集的字符串。模式使用星号(*)作为通配符。
#1
2
clientConfig.setIncludeEnvVars()
accepts a boolean values and control whether to include the env vars as part of the build info.
clientConfig.setIncludeEnvVars()接受布尔值并控制是否包含env变量作为构建信息的一部分。
You should use either:
你应该使用:
clientConfig.setEnvVarsExcludePatterns('*password*,*secret*')
or
要么
clientConfig.setEnvVarsIncludePatterns('*not-secret*')
Both methods accepts a string which contains a comma delimited set of patterns. The patterns use star (*) as a wildcard.
两种方法都接受包含逗号分隔的模式集的字符串。模式使用星号(*)作为通配符。