是否可以在不运行gradle.run
任务的情况下执行artifactoryPublish
(见下文)?我认为我可以通过指定tasks参数来完成此任务,但插件似乎将任务添加回来。例如,以下内容:
def server = Artifactory.server('artifactory-primary')
def gradle = Artifactory.newGradleBuild()
gradle.resolver server: server, repo: 'gradle-all-virtual'
gradle.deployer server: server, repo: 'gradle-libs-snapshot-local'
gradle.deployer.mavenCompatible = true
gradle.useWrapper = true
gradle.usesPlugin = true
def buildInfo = gradle.run(
rootDir: ".",
buildFile: 'build.gradle',
tasks: 'build',
switches: '--no-daemon -x check')
server.publishBuildInfo buildInfo
结果:
...
gradlew -x check build artifactoryPublish -b build.gradle
...
当我真正想要的是:
...
gradlew -x check build -b build.gradle
...
最终我想在一个阶段构建并在另一个阶段部署。
相同的代码片段,但引用了从我的Gradle文件中移除的神器,并添加了Tamir的添加内容:
def server = Artifactory.server('artifactory-primary')
def gradle = Artifactory.newGradleBuild()
gradle.resolver server: server, repo: 'gradle-all-virtual'
gradle.deployer server: server, repo: 'gradle-libs-snapshot-local'
gradle.deployer.mavenCompatible = true
gradle.deployer.deployArtifacts = false
gradle.useWrapper = true
gradle.usesPlugin = false
def buildInfo = gradle.run(
rootDir: ".",
buildFile: 'build.gradle',
tasks: 'build',
switches: '--no-daemon -x check')
server.publishBuildInfo buildInfo
产生相同的结果。
答案 0 :(得分:4)
默认情况下会添加artifactoryPublish任务,您可以在Jenkins Artifactory plugin code中看到。
如果您不想将工件部署到工件,则可以通过配置deployer.deployArtifacts = false来实现。
在你的情况下:
gradle.deployer.deployArtifacts = false
如果您想分两个阶段构建项目,可以使用deployArtifacts = false构建它,第二次使用deployArtifacts = true构建它