Issue
I am successfully uploading my artifacts using the JFrong plugin.
I think I have set up everything for automatic deletion once the number of builds (artifacts) is more than 5. However my artifacts are not deleted (I have them more than maxBuilds
property). In the target repo and folder I can see higher number of artifacts than the maxBuilds. My user does have permission to delete artifact (I have tried it manually).
Did I configure everything properly? Thanks
stage ('Artifactory stage') {
steps {
rtServer (
id: 'Artifactory',
url: 'https://artifactory.domain/artifactory',
credentialsId: 'test',
timeout: 300
)
}
}
stage ('Build info stage ') {
steps {
rtBuildInfo (
maxBuilds: 5,
deleteBuildArtifacts: true
)
}
}
stage ('Upload stage') {
steps {
rtUpload (
serverId: 'Artifactory',
spec: '''{
"files": [
{
"pattern": "arena-*.zip",
"target": "project/packages/"
}
]
}''',
)
}
}
stage ('Publish build info') {
steps {
rtPublishBuildInfo (
serverId: 'Artifactory'
)
}
}
Log information at the end of the build...
[Pipeline] stage [Pipeline] { (Build info stage ) [Pipeline] rtBuildInfo [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Upload stage) [Pipeline] rtUpload [consumer_0] Deploying artifact: https://artifactory.domain/artifactory/packages/arena-2022-02-07-11-31-58.zip } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Publish build info) [Pipeline] rtPublishBuildInfo Deploying build info to: https://artifactory.domain/artifactory/api/build Deploying build descriptor to: https://artifactory.domain/artifactory/api/build Build successfully deployed. Browse it in Artifactory under https://artifactory.domain/artifactory/webapp/builds/UUEAW%20::%20ArenaWebRuf%20::%20master/81 Sending request for build retention, deleting build artifacts, max number of builds to store: 5. [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Declarative: Post Actions)
Solution
Add captureEnv: true
to rtBuildInfo
closure:
rtBuildInfo (
captureEnv: true
maxBuilds: 5,
deleteBuildArtifacts: true
)
Capturing Environment Variables
To set the Build-Info object to automatically capture environment variables while downloading and uploading files, add the following to your script.
By default, environment variables names which include "password", "psw", "secret", "token", or "key" (case insensitive) are excluded and will not be published to Artifactory.
Answered By - Pamela Sarkisyan
Answer Checked By - Timothy Miller (JavaFixing Admin)