Squirrel
Squirrel

Reputation: 1523

Retrieve Artifactory BuildInfo timestamp properties

I publish the BuildInfo to Artifactory using:

    def buildInfo = Artifactory.newBuildInfo()

    /* Set artifact properties */
    buildInfo.env.capture = true
    buildInfo.env.collect()

    // Publish the build to Artifactory
    server.upload spec: uploadSpec, buildInfo: buildInfo

I would like to retrieve the four property assigned to artifacts in Artifactory. I see properties being set such as build.name, build.number, build.timestamp, and vcs.revision

I can get the build number and name using:

    def buildName = buildInfo.name
    def buildNumber = buildInfo.number

How would I go about to retrieve the timestamp and vcs.number from the BuildInfo so that I can do a REST call and post the same four properties to a folder I create in Artifactory.

Upvotes: 2

Views: 876

Answers (2)

Squirrel
Squirrel

Reputation: 1523

I installed Jenkins Build Timestamp Plugin and used this UTC pattern "yyyy-MM-dd'T'HH:mm:ss.SSSZ"

In my groovy file, I added these two commands:

time=Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSSZ", BUILD_TIMESTAMP) epoch_milis = time.getTime()

Upvotes: 0

danf
danf

Reputation: 2709

Timestamp in buildinfo is called started, as for vcs.number I assume you mean revision?

Upvotes: 1

Related Questions