/** * @param build * set to non-null if {@link Fingerprint} to be created (if so) * will have this build as the owner. Otherwise null, to indicate * an owner-less build. * @throws IOException Loading error */ public @Nonnull Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @Nonnull String fileName, @Nonnull byte[] md5sum) throws IOException { return getOrCreate(build,fileName, Util.toHexString(md5sum)); }
Fingerprint addRecord(Run build) throws IOException { FingerprintMap map = Jenkins.getInstance().getFingerprintMap(); return map.getOrCreate(produced?build:null, fileName, md5sum); }
/** * @param build * set to non-null if {@link Fingerprint} to be created (if so) * will have this build as the owner. Otherwise null, to indicate * an owner-less build. */ public Fingerprint getOrCreate(AbstractBuild build, String fileName, byte[] md5sum) throws IOException { return getOrCreate(build,fileName, Util.toHexString(md5sum)); }
/** * @param build set to non-null if {@link Fingerprint} to be created (if so) * will have this build as the owner. Otherwise null, to indicate an * owner-less build. */ public Fingerprint getOrCreate(AbstractBuild build, String fileName, byte[] md5sum) throws IOException { return getOrCreate(build, fileName, Util.toHexString(md5sum)); }
/** * @param build * set to non-null if {@link Fingerprint} to be created (if so) * will have this build as the owner. Otherwise null, to indicate * an owner-less build. */ public Fingerprint getOrCreate(AbstractBuild build, String fileName, byte[] md5sum) throws IOException { return getOrCreate(build,fileName, Util.toHexString(md5sum)); }
/** * @param build * set to non-null if {@link Fingerprint} to be created (if so) * will have this build as the owner. Otherwise null, to indicate * an owner-less build. * @throws IOException Loading error */ public @Nonnull Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @Nonnull String fileName, @Nonnull byte[] md5sum) throws IOException { return getOrCreate(build,fileName, Util.toHexString(md5sum)); }
/** * @param build * set to non-null if {@link Fingerprint} to be created (if so) * will have this build as the owner. Otherwise null, to indicate * an owner-less build. */ public Fingerprint getOrCreate(AbstractBuild build, String fileName, byte[] md5sum) throws IOException { return getOrCreate(build,fileName, Util.toHexString(md5sum)); }
private static @Nonnull Fingerprint forDockerInstance(@CheckForNull Run<?,?> run, @Nonnull String id, @CheckForNull String name, @Nonnull String prefix) throws IOException { final Jenkins j = Jenkins.getInstance(); if (j == null) { throw new IOException("Jenkins instance is not ready"); } final String imageName = prefix + (StringUtils.isNotBlank(name) ? name : id); return j.getFingerprintMap().getOrCreate(run, imageName, getFingerprintHash(id)); }
public Void call(MavenBuild build) throws IOException, InterruptedException { FingerprintMap map = Hudson.getInstance().getFingerprintMap(); for (Entry<String, String> e : p.entrySet()) map.getOrCreate(build, e.getKey(), e.getValue()).add(build); for (Entry<String, String> e : u.entrySet()) map.getOrCreate(null, e.getKey(), e.getValue()).add(build); Map<String,String> all = new HashMap<String, String>(u); all.putAll(p); // add fingerprints to the build FingerprintAction.add(build, all); return null; } });
private static @Nonnull Fingerprint forDockerInstance(@CheckForNull Run<?,?> run, @Nonnull String id, @CheckForNull String name, @Nonnull String prefix) throws IOException { final Jenkins j = Jenkins.getInstance(); if (j == null) { throw new IOException("Jenkins instance is not ready"); } final String imageName = prefix + (StringUtils.isNotBlank(name) ? name : id); return j.getFingerprintMap().getOrCreate(run, imageName, getFingerprintHash(id)); }
/** * Called from within the master to record fingerprint. */ public void recordFingerprint(MavenBuild build) throws IOException { FingerprintMap map = Hudson.getInstance().getFingerprintMap(); map.getOrCreate(build,fileName,md5sum); }
public Void call(MavenBuild build) throws IOException, InterruptedException { FingerprintMap map = Jenkins.getInstance().getFingerprintMap(); for (Entry<String, String> e : p.entrySet()) map.getOrCreate(build, e.getKey(), e.getValue()).add(build); for (Entry<String, String> e : u.entrySet()) map.getOrCreate(null, e.getKey(), e.getValue()).add(build); Map<String,String> all = new HashMap<String, String>(u); all.putAll(p); // add action FingerprintAction fa = build.getAction(FingerprintAction.class); if (fa!=null) fa.add(all); else build.getActions().add(new FingerprintAction(build,all)); return null; } }
Fingerprint addRecord(AbstractBuild<?,?> build) throws IOException { FingerprintMap map = Jenkins.getInstance().getFingerprintMap(); return map.getOrCreate(produced?build:null, artifact.getName(), md5sum); }
@Nonnull private synchronized TriggerEntry getOrCreateEntry(@Nonnull final PushNotification pushNotification) throws IOException, InterruptedException { Fingerprint fingerprint = jenkins.getFingerprintMap().getOrCreate(null, pushNotification.getRepoName(), pushNotification.sha()); TriggerEntry entry = fingerprint.getFacet(TriggerEntry.class); if (entry==null) fingerprint.getFacets().add(entry=new TriggerEntry(fingerprint,pushNotification)); return entry; }
/** * Creates {@link FingerprintAction} for {@link MavenModuleSetBuild} * by aggregating all fingerprints from module builds. */ public static void aggregate(MavenModuleSetBuild mmsb) throws IOException { Map<String,String> records = new HashMap<String, String>(); for (List<MavenBuild> builds : mmsb.getModuleBuilds().values()) { for (MavenBuild build : builds) { FingerprintAction fa = build.getAction(FingerprintAction.class); if(fa!=null) records.putAll(fa.getRecords()); } } if(!records.isEmpty()) { FingerprintMap map = Hudson.getInstance().getFingerprintMap(); for (Entry<String, String> e : records.entrySet()) map.getOrCreate(null, e.getKey(), e.getValue()).add(mmsb); mmsb.addAction(new FingerprintAction(mmsb,records)); } }
/** * Creates {@link FingerprintAction} for {@link MavenModuleSetBuild} * by aggregating all fingerprints from module builds. */ public static void aggregate(MavenModuleSetBuild mmsb) throws IOException { Map<String,String> records = new HashMap<>(); for (List<MavenBuild> builds : mmsb.getModuleBuilds().values()) { for (MavenBuild build : builds) { FingerprintAction fa = build.getAction(FingerprintAction.class); if(fa!=null) records.putAll(fa.getRecords()); } } if(!records.isEmpty()) { FingerprintMap map = Jenkins.getInstance().getFingerprintMap(); for (Entry<String, String> e : records.entrySet()) map.getOrCreate(null, e.getKey(), e.getValue()).add(mmsb); mmsb.addAction(new FingerprintAction(mmsb,records)); } }
/** * Creates a fingerprint that can be used to track the usage of a specific credential. * * @param c the credential to fingerprint. * @return the Fingerprint. * @throws IOException if the credential's fingerprint hash could not be computed. * @since 2.1.1 */ @NonNull public static Fingerprint getOrCreateFingerprintOf(@NonNull Credentials c) throws IOException { String pseudoFilename = String.format("Credential id=%s name=%s", c instanceof IdCredentials ? ((IdCredentials) c).getId() : "unknown", CredentialsNameProvider.name(c)); try { MessageDigest md5 = MessageDigest.getInstance("MD5"); DigestOutputStream out = new DigestOutputStream(new NullOutputStream(), md5); try { FINGERPRINT_XML.toXML(c, new OutputStreamWriter(out, Charset.forName("UTF-8"))); } finally { IOUtils.closeQuietly(out); } return Jenkins.getActiveInstance().getFingerprintMap().getOrCreate(null, pseudoFilename, md5.digest()); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("JLS mandates MD5 as a supported digest algorithm"); } }
/** * Creates a fingerprint that can be used to track the usage of a specific credential. * * @param c the credential to fingerprint. * @return the Fingerprint. * @throws IOException if the credential's fingerprint hash could not be computed. * @since 2.1.1 */ @NonNull public static Fingerprint getOrCreateFingerprintOf(@NonNull Credentials c) throws IOException { String pseudoFilename = String.format("Credential id=%s name=%s", c instanceof IdCredentials ? ((IdCredentials) c).getId() : "unknown", CredentialsNameProvider.name(c)); try { MessageDigest md5 = MessageDigest.getInstance("MD5"); DigestOutputStream out = new DigestOutputStream(new NullOutputStream(), md5); try { FINGERPRINT_XML.toXML(c, new OutputStreamWriter(out, Charset.forName("UTF-8"))); } finally { IOUtils.closeQuietly(out); } return Jenkins.getActiveInstance().getFingerprintMap().getOrCreate(null, pseudoFilename, md5.digest()); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("JLS mandates MD5 as a supported digest algorithm"); } }
/** * Registers a fingerprint for the given workspace's id. * * @param exws the workspace to register the fingerprint for * @throws IOException if fingerprint load operation fails */ private void registerFingerprint(ExternalWorkspace exws) throws IOException { FingerprintMap map = Jenkins.getActiveInstance().getFingerprintMap(); Fingerprint f = map.getOrCreate(run, exws.getDisplayName(), exws.getId()); if (f.getFacet(WorkspaceBrowserFacet.class) == null) { f.getFacets().add(new WorkspaceBrowserFacet(f, System.currentTimeMillis(), exws)); } f.save(); }
FingerprintMap map = Jenkins.getInstance().getFingerprintMap(); Fingerprint f = map.getOrCreate(src, record.getName(), record.getFingerprint()); if (src!=null) { f.add((AbstractBuild)src);