本文整理汇总了Java中hudson.model.Fingerprint类的典型用法代码示例。如果您正苦于以下问题:Java Fingerprint类的具体用法?Java Fingerprint怎么用?Java Fingerprint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Fingerprint类属于hudson.model包,在下文中一共展示了Fingerprint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBrowse
import hudson.model.Fingerprint; //导入依赖的package包/类
/**
* Method accessed by the Stapler framework when the following url is accessed:
* <i>JENKINS_ROOT_URL/exws/browse/workspaceId/</i>
*
* @param workspaceId the workspace's unique id
* @return the workspace whose id matches the given input id, or {@link NoFingerprintMatch} if fingerprint is not found
* @throws IOException if fingerprint load operation fails
* @throws IllegalArgumentException if {@link WorkspaceBrowserFacet} is not registered for the matching fingerprint
*/
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused")
@Nonnull
public Object getBrowse(String workspaceId) throws IOException {
Fingerprint fingerprint = Jenkins.getActiveInstance()._getFingerprint(workspaceId);
if (fingerprint == null) {
return new NoFingerprintMatch(workspaceId);
}
WorkspaceBrowserFacet facet = fingerprint.getFacet(WorkspaceBrowserFacet.class);
if (facet == null) {
throw new IllegalArgumentException("Couldn't find the Fingerprint Facet that holds the Workspace metadata");
}
return facet.getWorkspace();
}
示例2: withRunCommand
import hudson.model.Fingerprint; //导入依赖的package包/类
@Test public void withRunCommand() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
assumeDocker();
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj");
p.setDefinition(new CpsFlowDefinition(
" docker.image('maven:3.3.9-jdk-8').withRun(\"--entrypoint mvn\", \"-version\") {c ->\n" +
" sh \"docker logs ${c.id}\"" +
"}", true));
story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
DockerClient client = new DockerClient(new Launcher.LocalLauncher(StreamTaskListener.NULL), null, null);
String mavenIID = client.inspect(new EnvVars(), "maven:3.3.9-jdk-8", ".Id");
Fingerprint f = DockerFingerprints.of(mavenIID);
assertNotNull(f);
DockerRunFingerprintFacet facet = f.getFacet(DockerRunFingerprintFacet.class);
assertNotNull(facet);
}
});
}
示例3: assertBuild
import hudson.model.Fingerprint; //导入依赖的package包/类
private void assertBuild(final String projectName, final String piplineCode) throws Exception {
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
assumeDocker();
WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, projectName);
p.setDefinition(new CpsFlowDefinition(piplineCode, true));
WorkflowRun b = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
DockerClient client = new DockerClient(new LocalLauncher(StreamTaskListener.NULL), null, null);
String ancestorImageId = client.inspect(new EnvVars(), "hello-world", ".Id");
story.j.assertLogContains("built from-with-arg", b);
story.j.assertLogContains(ancestorImageId.replaceFirst("^sha256:", "").substring(0, 12), b);
Fingerprint f = DockerFingerprints.of(ancestorImageId);
assertNotNull(f);
DockerDescendantFingerprintFacet descendantFacet = f.getFacet(DockerDescendantFingerprintFacet.class);
assertNotNull(descendantFacet);
}
});
}
示例4: addRunFacet
import hudson.model.Fingerprint; //导入依赖的package包/类
/**
* Adds a new {@link ContainerRecord} for the specified image, creating necessary intermediate objects as it goes.
*/
public static void addRunFacet(@Nonnull ContainerRecord record, @Nonnull Run<?,?> run) throws IOException {
String imageId = record.getImageId();
Fingerprint f = forImage(run, imageId);
Collection<FingerprintFacet> facets = f.getFacets();
DockerRunFingerprintFacet runFacet = null;
for (FingerprintFacet facet : facets) {
if (facet instanceof DockerRunFingerprintFacet) {
runFacet = (DockerRunFingerprintFacet) facet;
break;
}
}
BulkChange bc = new BulkChange(f);
try {
if (runFacet == null) {
runFacet = new DockerRunFingerprintFacet(f, System.currentTimeMillis(), imageId);
facets.add(runFacet);
}
runFacet.add(record);
runFacet.addFor(run);
DockerFingerprintAction.addToRun(f, imageId, run);
bc.commit();
} finally {
bc.abort();
}
}
示例5: test_readResolve
import hudson.model.Fingerprint; //导入依赖的package包/类
@Test
public void test_readResolve() throws Exception {
FreeStyleProject p = rule.createFreeStyleProject("test");
FreeStyleBuild b = rule.assertBuildStatusSuccess(p.scheduleBuild2(0));
ContainerRecord r1 = new ContainerRecord("192.168.1.10", "cid", IMAGE_ID, "magic", System.currentTimeMillis(), Collections.<String, String>emptyMap());
DockerFingerprints.addRunFacet(r1, b);
Fingerprint fingerprint = DockerFingerprints.of(IMAGE_ID);
DockerRunFingerprintFacet facet = new DockerRunFingerprintFacet(fingerprint, System.currentTimeMillis(), IMAGE_ID);
ContainerRecord r2 = new ContainerRecord("192.168.1.10", "cid", null, "magic", System.currentTimeMillis(), Collections.<String, String>emptyMap());
facet.add(r2);
Assert.assertNull(r2.getImageId());
facet.readResolve();
Assert.assertEquals(IMAGE_ID, r2.getImageId());
// Check that actions have been automatically added
DockerFingerprintAction fpAction = b.getAction(DockerFingerprintAction.class);
Assert.assertNotNull("DockerFingerprintAction should be added automatically", fpAction);
Assert.assertTrue("Docker image should be referred in the action",
fpAction.getImageIDs().contains(IMAGE_ID));
}
示例6: getLastInspectImageResponse
import hudson.model.Fingerprint; //导入依赖的package包/类
/**
* Retrieves the last {@link InspectImageResponse} for the specified image.
* @param imageId Image Id
* @return Last available report. Null if there is no data available
* (or if an internal exception happens)
*/
public static @CheckForNull InspectImageResponse getLastInspectImageResponse(@Nonnull String imageId) {
try {
final Fingerprint fp = DockerFingerprints.of(imageId);
if (fp != null) {
final DockerInspectImageFacet facet = FingerprintsHelper.getFacet(fp, DockerInspectImageFacet.class);
if (facet != null) {
return facet.getData();
}
}
return null;
} catch (IOException ex) {
LOGGER.log(Level.WARNING, "Cannot retrieve deployment reports for imageId="+imageId, ex);
return null;
}
}
示例7: assertNotNull
import hudson.model.Fingerprint; //导入依赖的package包/类
/**
* Checks that the existence {@link DockerDeploymentFacet}.
* @param containerId Container ID
* @param imageId image ID
* @return Facet (if validation passes)
* @throws IOException test failure
* @throws AssertionError Validation failure
*/
private @Nonnull DockerDeploymentFacet assertExistsDeploymentFacet
(@Nonnull String containerId, @Nonnull String imageId) throws IOException {
final Fingerprint containerFP = DockerTraceabilityHelper.ofValidated(containerId);
assertNotNull(containerFP);
final DockerDeploymentFacet containerFacet =
FingerprintsHelper.getFacet(containerFP, DockerDeploymentFacet.class);
assertNotNull(containerFacet);
assertEquals(1, containerFacet.getDeploymentRecords().size());
final DockerContainerRecord record = containerFacet.getLatest();
assertNotNull(containerFacet.getLatest());
assertEquals(containerId, record.getContainerId());
assertEquals(DockerTraceabilityHelper.getImageHash(imageId), record.getImageFingerprintHash());
return containerFacet;
}
示例8: addToFacets
import hudson.model.Fingerprint; //导入依赖的package包/类
private DeployedApplicationLocation addToFacets(Map.Entry<String, DeployedApplicationLocation> pair) throws IOException {
DeployedApplicationLocation location = pair.getValue();
String md5sum = pair.getKey();
if (!NO_MD5.equals(md5sum)) {
Jenkins j = Jenkins.getInstance();
if (j == null) {
throw new IllegalStateException("Jenkins has not been started, or was already shut down");
}
Fingerprint fingerprint = j._getFingerprint(md5sum);
if (fingerprint != null) {
fingerprint.getFacets()
.add(new DeployedApplicationFingerprintFacet<DeployedApplicationLocation>(fingerprint,
System.currentTimeMillis(),
location));
fingerprint.save();
listener.getLogger().println("[cloudbees-deployer] Recorded deployment in fingerprint record");
} else {
listener.getLogger()
.println("[cloudbees-deployer] Deployed artifact does not have a fingerprint record");
}
}
return location;
}
示例9: initPython
import hudson.model.Fingerprint; //导入依赖的package包/类
private void initPython() {
if (pexec == null) {
pexec = new PythonExecutor(this);
String[] jMethods = new String[1];
jMethods[0] = "createFor";
String[] pFuncs = new String[1];
pFuncs[0] = "create_for";
Class[][] argTypes = new Class[1][];
argTypes[0] = new Class[2];
argTypes[0][0] = Fingerprint.class;
argTypes[0][1] = List.class;
pexec.checkAbstrMethods(jMethods, pFuncs, argTypes);
String[] functions = new String[0];
int[] argsCount = new int[0];
pexec.registerFunctions(functions, argsCount);
}
}
示例10: registerFingerprint
import hudson.model.Fingerprint; //导入依赖的package包/类
/**
* 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();
}
示例11: updateFingerprint
import hudson.model.Fingerprint; //导入依赖的package包/类
/**
* Adds the current run to the fingerprint's usages.
*
* @param workspaceId the workspace's id
* @throws IOException if fingerprint load operation fails,
* or if no fingerprint is found for the given workspace id
*/
private void updateFingerprint(String workspaceId) throws IOException {
Fingerprint f = Jenkins.getActiveInstance()._getFingerprint(workspaceId);
if (f == null) {
throw new AbortException("Couldn't find any Fingerprint for: " + workspaceId);
}
Fingerprint.RangeSet set = f.getUsages().get(run.getParent().getFullName());
if (set == null || !set.includes(run.getNumber())) {
f.addFor(run);
f.save();
}
}
示例12: deleteCredential
import hudson.model.Fingerprint; //导入依赖的package包/类
private static void deleteCredential(String id, NamespaceName name,
String resourceRevision) throws IOException {
Credentials existingCred = lookupCredentials(id);
if (existingCred != null) {
final SecurityContext previousContext = ACL.impersonate(ACL.SYSTEM);
try {
Fingerprint fp = CredentialsProvider
.getFingerprintOf(existingCred);
if (fp != null && fp.getJobs().size() > 0) {
// per messages in credentials console, it is not a given,
// but
// it is possible for job refs to a credential to be
// tracked;
// if so, we will not prevent deletion, but at least note
// things
// for potential diagnostics
StringBuffer sb = new StringBuffer();
for (String job : fp.getJobs())
sb.append(job).append(" ");
logger.info("About to delete credential " + id
+ "which is referenced by jobs: " + sb.toString());
}
CredentialsStore s = CredentialsProvider
.lookupStores(Jenkins.getActiveInstance()).iterator()
.next();
s.removeCredentials(Domain.global(), existingCred);
logger.info("Deleted credential " + id + " from Secret " + name
+ " with revision: " + resourceRevision);
s.save();
} finally {
SecurityContextHolder.setContext(previousContext);
}
}
}
示例13: verifyFileIsFingerPrinted
import hudson.model.Fingerprint; //导入依赖的package包/类
private void verifyFileIsFingerPrinted(WorkflowJob pipeline, WorkflowRun build, String fileName) throws java.io.IOException {
System.out.println(getClass() + " verifyFileIsFingerPrinted(" + build + ", " + fileName + ")");
Fingerprinter.FingerprintAction fingerprintAction = build.getAction(Fingerprinter.FingerprintAction.class);
Map<String, String> records = fingerprintAction.getRecords();
System.out.println(getClass() + " records: " + records);
String jarFileMd5sum = records.get(fileName);
assertThat(jarFileMd5sum, not(nullValue()));
Fingerprint jarFileFingerPrint = jenkinsRule.getInstance().getFingerprintMap().get(jarFileMd5sum);
assertThat(jarFileFingerPrint.getFileName(), is(fileName));
assertThat(jarFileFingerPrint.getOriginal().getJob().getName(), is(pipeline.getName()));
assertThat(jarFileFingerPrint.getOriginal().getNumber(), is(build.getNumber()));
}
示例14: ofNoException
import hudson.model.Fingerprint; //导入依赖的package包/类
private static @CheckForNull Fingerprint ofNoException(@Nonnull String id) {
try {
return of(id);
} catch (IOException ex) { // The error is not a hazard in CheckForNull logic
LOGGER.log(Level.WARNING, "Cannot retrieve a fingerprint for Docker id="+id, ex);
}
return null;
}
示例15: forDockerInstance
import hudson.model.Fingerprint; //导入依赖的package包/类
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));
}