use of jenkins.model.Jenkins in project blueocean-plugin by jenkinsci.
the class CachesTest method setup.
@Before
public void setup() {
jenkins = mock(Jenkins.class);
when(jenkins.getFullName()).thenReturn("");
Folder folder = mock(Folder.class);
when(folder.getParent()).thenReturn(jenkins);
when(folder.getFullName()).thenReturn("/Repo");
when(jenkins.getItem("/Repo")).thenReturn(folder);
job = mock(Job.class);
when(job.getParent()).thenReturn(folder);
when(job.getFullName()).thenReturn("cool-branch");
when(jenkins.getItemByFullName("/Repo/cool-branch", Job.class)).thenReturn(job);
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class SupportPlugin method threadDumpStartup.
@Initializer(after = InitMilestone.STARTED)
public static void threadDumpStartup() throws Exception {
if (!logStartupPerformanceIssues)
return;
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
final File f = new File(getRootDirectory(), "/startup-threadDump" + dateFormat.format(new Date()) + ".txt");
if (!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
Thread t = new Thread("Support core plugin startup diagnostics") {
@Override
public void run() {
while (true) {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null || jenkins.getInitLevel() != InitMilestone.COMPLETED) {
continue;
}
PrintStream ps = null;
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(f, true);
ps = new PrintStream(fileOutputStream, false, "UTF-8");
ps.println("=== Thread dump at " + new Date() + " ===");
ThreadDumps.threadDump(fileOutputStream);
// Generate a thread dump every few seconds/minutes
ps.flush();
Thread.sleep(TimeUnit.SECONDS.toMillis(secondsPerThreadDump));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
org.apache.commons.io.IOUtils.closeQuietly(ps);
org.apache.commons.io.IOUtils.closeQuietly(fileOutputStream);
}
}
}
};
t.start();
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class ConfigFileComponent method addContents.
@Override
public void addContents(@NonNull Container container) {
Jenkins jenkins = Jenkins.getInstance();
File configFile = new File(jenkins.getRootDir(), "config.xml");
if (configFile.exists()) {
container.add(new XmlRedactedSecretFileContent("jenkins-root-configuration-files/" + configFile.getName(), configFile));
} else {
// this should never happen..
LOGGER.log(Level.WARNING, "Jenkins global config file does not exist.");
}
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class ProcFilesRetriever method addContents.
@Override
public void addContents(@NonNull Container container) {
Jenkins j = Jenkins.getInstance();
addUnixContents(container, j);
for (Node node : j.getNodes()) {
addUnixContents(container, node);
}
}
use of jenkins.model.Jenkins in project support-core-plugin by jenkinsci.
the class RootCAs method addContents.
private void addContents(@NonNull Container container, @NonNull final Node node) {
Computer c = node.toComputer();
if (c == null) {
return;
}
String name;
if (node instanceof Jenkins) {
name = "master";
} else {
name = "slave/" + node.getNodeName();
}
container.add(new Content("nodes/" + name + "/RootCA.txt") {
@Override
public void writeTo(OutputStream os) throws IOException {
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os, "utf-8")));
try {
out.println(getRootCA(node));
} catch (IOException e) {
SupportLogFormatter.printStackTrace(e, out);
} finally {
out.flush();
}
}
});
}
Aggregations