Hello all, I've learned a ton from this google group and now I think I've
run into something new.
Background: We have created 15 deployment pipelines for applications in our
platform to deploy into a Dev integration environment and a QA environment
using a single deploy job for each destination. When the root job of the
pipelines has successfully pushed through the QA deploy we are including
that root job build in another pipeline which pushes all applications to
other environments.
Central function: We rely on Project Relationship (using
getRelationship)and fingerprints. We create a special file for
fingerprinting in each build: %JOB_NAME%_%BUILD_NUMBER%.fingerprint
Issue: We find that sometimes the project relationship is not created even
though the fingerprint file was created, archived in the root job, and
archived in each downstream deploy job.
Workaround: We find we can repair the relationship by deleting the deploy
builds, changing the affected pipeline to manual trigger steps and then
executing each build pipeline step again. Thus the same root job was
deployed a 2nd time but this time the project relationship exists.
(Confirmed by using the project relationship page to compare root job to
each downstream deploy job)
Note: Build pipeline appearance sample as follows
App-ABC > Deploy D1 > Deploy Q1
App-DEF > Deploy D1 > Deploy Q1
AllApp >Deploy Q2 > Deploy Stress > Deploy UAT
(AllApp uses groovy to CopyArtifact from latest relationship between App-*
and Deploy Q1)
groovy snippet which chooses the build number of the root job for
copyartifact
//Get the relationship of upstream job build # to downstream job
build number
//If the downstream job was run more than one time for a single
upstream build then the rangeset will have number values per Key.
//The key is the upstream job's build number
SortedMap<Integer, Fingerprint.RangeSet> relationship =
uProj.getRelationship(relationProj);
// Iterate through the relationships between matched job and this
upstream job
// Because they come out last build first, we will break the loop
when a successful match build is found
for( Map.Entry<Integer, Fingerprint.RangeSet> entry :
relationship.entrySet())
{
buildByNumber= uProj.getBuildByNumber(entry.getKey());
//Get Upstream build so we can print it's name
println(entry.getKey() +" | "+entry.getValue());
//Print the Upstream build number | downstream associated builds
dbuilds = relationProj.getBuilds(entry.getValue()); //Get
list of matched builds correcponding to this upstream build
for(AbstractBuild dbuild : dbuilds)
{
if(dbuild.getResult()==hudson.model.Result.SUCCESS)
{
String defaultDate = "01/01/2014 00:00:00";
java.util.Date parsedDate;
try{
SimpleDateFormat formatter = new
SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
parsedDate= formatter.parse(minDate);
} catch (ParseException ex) {
println ("Date parsing failed: " +minDate);
parsedDate= formatter.parse(defaultDate);
}
if(dbuild.getTime().after(parsedDate))
{
println ("Last " +relationProj.getName() +" SUCCESS
at Build Number " + dbuild.number + " From " + dbuild.getTime().toString());
//buildnumber=entry.getKey();
//break;
}
}
}
Thanks for reading
Ken
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.