EDIT: Sorry about formatting :( I'm new to this.. will try to clean it up.
I'm using a declarative Jenkinsfile to build and publish Maven and Gradle artifacts with buildInfo to Artifactory trying to separate each action (stage1=build, stage2=publish) in distinct stages but am unable to figure out how to do so.
Trying to figure out a working Declarative Pipeline syntax code to use with Artifactory to separate build and publishing stages. All the examples I've found are either incomplete, non-working or for scripted pipeline only.
I've tried the instructions found here https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins
For Maven, setting 'deployArtifacts: false' in the rtMavenDeployer directive results in the buildinfo not being published, but the artifact is still deployed using goals 'clean install'.
org.jfrog.build.extractor.maven.BuildInfoClientBuilder - Deploying >artifact: xxx
In the log we see (with deployArtifacts: false): Artifactory Build Info Recorder: publish build info set to false, build info will not be published...
steps {
rtMavenDeployer (
...
deployArtifacts: false )
in a later stage we use rtPublishBuildInfo () to publish the actual buildInfo to Artifactory.
I've also tried to create two separate rtMavenDeployer's to be used for build and one for deploy.
for ex.
rtMavenDeployer (
id: builder
deployArtifacts: false
)
rtMavenDeployer (
id: deployer
deployArtifacts: true
)
Later references in respective build and publish stages using BUILD STAGE:
rtMavenRun(
deployerId: 'builder'
goals: 'clean install'
)
DEPLOY STAGE:
rtMavenRun(
deployerId: 'deployer'
goals: 'install'
)
rtPublishBuildInfo()
Resulting in duplicate buildInfo in Artifactory and x2 inflated registered artifacts...
Is there a clear way for this separation of actions in a declarative pipeline?
Expect to be able to build an artifact using Declarative Pipeline syntax in one stage and deploy the actual Maven/Gradle artifact with buildInfo at a later stage.
This is how it's done in separate stages in a scripted pipeline from what I understand:
stage ('Test') {
rtMaven.run pom: 'maven-example/pom.xml', goals: 'clean test'
}
stage ('Install') {
rtMaven.run pom: 'maven-example/pom.xml', goals: 'install', buildInfo: buildInfo
}
stage ('Deploy') {
rtMaven.deployer.deployArtifacts buildInfo
}
stage ('Publish build info') {
server.publishBuildInfo buildInfo
}
}