KBEC-00314 - How to get all version information of a Artifact?

Summary

When there's a job and as the result of the job, sometimes I would like to get the all version information of my Artifact which is created by the job.

But, when I run findArtifactVersions to get this, it only returns latest version.

What function should I use to retrieve this properly?

Solution

To get the list of artifacts published by a job, you need to use the "findObjects" API to look up artifact versions by the publisher job ID.

   <Example>

use strict;
use warnings;use ElectricCommander;use strict;use warnings;
use ElectricCommander;
my $ec = new ElectricCommander;
my $jobId = $ec->getProperty("/myJob/jobId")->findvalue("//value")->value();
my $response = $ec->findObjects("artifactVersion", {
    filter => [
        {
            propertyName => "publisherJobId",
            operator => "equals",
            operand1 => $jobId
        }
    ]
});
foreach my $av($response->findnodes("//artifactVersion")) {
    $ec->setProperty(
        "/myJob/published_artifacts/" . $av->findvalue("artifactName")->value(),
        $av->findvalue("version")->value()
    );
}
my $ec = new ElectricCommander;

This example show how to define findObjects function and how to put the result to property sheet.

See Also

findObjects

Applies to

  • Product versions: 4.x or later
  • OS versions: All
Have more questions? Submit a request

Comments

Powered by Zendesk