本文整理匯總了Java中hudson.model.AbstractBuild類的典型用法代碼示例。如果您正苦於以下問題:Java AbstractBuild類的具體用法?Java AbstractBuild怎麽用?Java AbstractBuild使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AbstractBuild類屬於hudson.model包,在下文中一共展示了AbstractBuild類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkProjectKeyIfVariable
import hudson.model.AbstractBuild; //導入依賴的package包/類
public JobConfigData checkProjectKeyIfVariable(JobConfigData jobConfigData, AbstractBuild build, BuildListener listener) throws QGException {
String projectKey = jobConfigData.getProjectKey();
if (projectKey.isEmpty()) {
throw new QGException("Empty project key.");
}
final JobConfigData envVariableJobConfigData = new JobConfigData();
envVariableJobConfigData.setSonarInstanceName(jobConfigData.getSonarInstanceName());
try {
envVariableJobConfigData.setProjectKey(getProjectKey(projectKey, build.getEnvironment(listener)));
} catch (IOException | InterruptedException e) {
throw new QGException(e);
}
envVariableJobConfigData.setSonarInstanceName(jobConfigData.getSonarInstanceName());
return envVariableJobConfigData;
}
示例2: getEnVars
import hudson.model.AbstractBuild; //導入依賴的package包/類
@Nonnull
public static Map<String, String> getEnVars(@Nonnull Run<?, ?> run) throws EnvInjectException {
Action envInjectAction = EnvInjectActionRetriever.getEnvInjectAction(run);
if (envInjectAction != null) {
try {
Method method = envInjectAction.getClass().getMethod("getEnvMap");
return (Map<String, String>) method.invoke(envInjectAction);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassCastException e) {
throw new EnvInjectException(e);
}
}
// Retrieve node used for this build
Node builtOn = (run instanceof AbstractBuild) ? ((AbstractBuild)run).getBuiltOn() : null;
// Check if node is always on. Otherwise, gather master env vars
if (builtOn == null) {
return getFallBackMasterNode(run.getParent());
}
if (builtOn.getRootPath() == null) {
return getFallBackMasterNode(run.getParent());
}
// Get envVars from the node of the last build
return getDefaultEnvVarsJob(run.getParent(), builtOn);
}
示例3: perform
import hudson.model.AbstractBuild; //導入依賴的package包/類
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
// Get VSO build environments
Map<String, String> env = build.getBuildVariables();
String tfsBuildIdStr = env.get("TfsBuildId" + build.getId());
// No build was queued on tfs, return
if (tfsBuildIdStr == null) {
return false;
}
int tfsBuildId = Integer.parseInt(tfsBuildIdStr);
try {
TfsClient client = getTfsClientFactory().getValidatedClient(this.serverUrl, this.username, this.password);
TfsBuildFacade tfsBuildFacade = getTfsBuildFacadeFactory().getBuildOnTfs(tfsBuildId, build, client);
tfsBuildFacade.finishAllTaskRecords();
tfsBuildFacade.finishBuild();
} catch (Exception e) {
e.printStackTrace();
logger.severe(e.getMessage());
return false;
}
return true;
}
示例4: finishBuild
import hudson.model.AbstractBuild; //導入依賴的package包/類
/**
* Update TFS Build status to finished with Jenkins status
*/
public void finishBuild() {
Build b = queryTfsBuild();
b.setFinishTime(new Date());
AbstractBuild jenkinsBuild = getJenkinsBuild();
BuildResult tfsResult = convertToTfsBuildResult(jenkinsBuild.getResult());
b.setResult(tfsResult);
b.setStatus(BuildStatus.COMPLETED);
String commitSha1 = getSourceCommit();
logger.info("Setting TFS build sourceVersion to: " + commitSha1);
b.setSourceVersion(commitSha1);
getClient().getBuildClient().updateBuild(b, b.getProject().getId(), b.getId());
}
示例5: constructEnvVars
import hudson.model.AbstractBuild; //導入依賴的package包/類
/**
* Constructs the environment variables for the current build.
*
* @return the current build environment variables
* @throws IOException
* @throws InterruptedException
*/
private EnvVars constructEnvVars() throws IOException, InterruptedException {
EnvVars envVars = build.getEnvironment(listener);
if (build instanceof AbstractBuild) {
envVars.putAll(((AbstractBuild<?, ?>) build).getBuildVariables()); // Add in matrix axes..
} else {
// Abstract#getEnvironment(TaskListener) put build parameters to
// environments, but Run#getEnvironment(TaskListener) doesn't.
// That means we can't retrieve build parameters from WorkflowRun
// as it is a subclass of Run, not of AbstractBuild.
// We need expand build parameters manually.
// See JENKINS-26694, JENKINS-30357 for details.
for (ParametersAction pa : build.getActions(ParametersAction.class)) {
// We have to extract parameters manually as ParametersAction#buildEnvVars
// (overrides EnvironmentContributingAction#buildEnvVars)
// is applicable only for AbstractBuild.
for (ParameterValue pv : pa.getParameters()) {
pv.buildEnvironment(build, envVars);
}
}
}
return envVars;
}
示例6: perform
import hudson.model.AbstractBuild; //導入依賴的package包/類
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
BuildListener listener) throws InterruptedException, IOException {
EnvVars envVars = build.getEnvironment(listener);
String expandedFilename = envVars.expand(filename);
String expandedContent = envVars.expand(content);
FilePath file = build.getWorkspace().child(expandedFilename);
file.write(expandedContent, encoding);
return true;
}
示例7: perform
import hudson.model.AbstractBuild; //導入依賴的package包/類
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
throws InterruptedException, IOException {
for (Cause.UpstreamCause c: Util.filter(build.getCauses(), Cause.UpstreamCause.class)) {
Job<?,?> upstreamProject = Jenkins.getInstance().getItemByFullName(c.getUpstreamProject(), Job.class);
if (upstreamProject == null) {
listener.getLogger().println(String.format("Not Found: %s", c.getUpstreamProject()));
continue;
}
Run<?,?> upstreamBuild = upstreamProject.getBuildByNumber(c.getUpstreamBuild());
if (upstreamBuild == null) {
listener.getLogger().println(String.format("Not Found: %s - %d", upstreamProject.getFullName(), c.getUpstreamBuild()));
continue;
}
listener.getLogger().println(String.format("Removed: %s - %s", upstreamProject.getFullName(), upstreamBuild.getFullDisplayName()));
upstreamBuild.delete();
}
return true;
}
示例8: perform
import hudson.model.AbstractBuild; //導入依賴的package包/類
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
//To change body of generated methods, choose Tools | Templates.
LogOutput log = new LogOutput();
Runtime runtime = Runtime.getRuntime();
Process process = null;
try {
String script = generateScript();
process = runScript(runtime, script);
log.logOutput(listener, process);
} catch (Throwable cause) {
log.logOutput(listener, process);
}
return true;
}
示例9: startTestExecution
import hudson.model.AbstractBuild; //導入依賴的package包/類
public void startTestExecution(AbstractBuild<?, ?> build, TaskListener listener) throws InterruptedException, IOException {
final RestTemplate restTemplate = new RestTemplate();
final PrintStream logger = listener.getLogger();
logger.println("\n\nJagger JaaS Jenkins Plugin Step 1: Creating TestExecution request...");
TestExecutionEntity testExecutionEntity = createTestExecution(logger);
logger.println("\n\nJagger JaaS Jenkins Plugin Step 2: Sending request to JaaS...");
TestExecutionEntity sentExecution = sendTestExecutionToJaas(logger, testExecutionEntity, restTemplate);
logger.println("\n\nJagger JaaS Jenkins Plugin Step 3: Waiting test to start execution...");
waitTestExecutionStarted(logger, sentExecution.getId(), restTemplate);
logger.println("\n\nJagger JaaS Jenkins Plugin Step 4: Waiting test to finish execution...");
TestExecutionEntity executionFinished = waitTestExecutionFinished(logger, sentExecution.getId(), restTemplate);
logger.println("\n\nJagger JaaS Jenkins Plugin Step 5: Publishing Test execution results...");
publishReportLink(logger, build, executionFinished);
checkDecision(logger, build, executionFinished.getSessionId(), restTemplate);
}
示例10: newTelegramService
import hudson.model.AbstractBuild; //導入依賴的package包/類
public TelegramService newTelegramService(AbstractBuild r, BuildListener listener) {
String authToken = this.authToken;
if (StringUtils.isEmpty(authToken)) {
authToken = getDescriptor().getToken();
}
String chatId = this.chatId;
if (StringUtils.isEmpty(chatId)) {
chatId = getDescriptor().getChatId();
}
EnvVars env = null;
try {
env = r.getEnvironment(listener);
} catch (Exception e) {
listener.getLogger().println("Error retrieving environment vars: " + e.getMessage());
env = new EnvVars();
}
authToken = env.expand(authToken);
chatId = env.expand(chatId);
return new StandardTelegramService(authToken, chatId);
}
示例11: testResiliency
import hudson.model.AbstractBuild; //導入依賴的package包/類
/**
* An exception adding the first label add should not disrupt the next label
*/
@Test
public void testResiliency()
throws Exception
{
AddComment addComment = new AddComment(false, "Test Comment");
addComment.setJiraClientSvc(jiraClientSvc);
AbstractBuild mockBuild = mock(AbstractBuild.class);
when(mockBuild.getEnvironment(any(TaskListener.class))).thenReturn(new EnvVars());
List<JiraCommit> jiraCommits = new ArrayList<>();
jiraCommits.add(new JiraCommit("SSD-101", MockChangeLogUtil.mockChangeLogSetEntry("Test Comment")));
jiraCommits.add(new JiraCommit("SSD-102", MockChangeLogUtil.mockChangeLogSetEntry("Test Comment")));
doThrow(new RuntimeException("Issue is invalid"))
.when(jiraClientSvc).addCommentToTicket("SSD-101", "Test Comment");
addComment.perform(jiraCommits, mockBuild, mock(Launcher.class), new StreamBuildListener(System.out, Charset.defaultCharset()));
verify(jiraClientSvc, times(1)).addCommentToTicket("SSD-101", "Test Comment");
verify(jiraClientSvc, times(1)).addCommentToTicket("SSD-102", "Test Comment");
}
示例12: started
import hudson.model.AbstractBuild; //導入依賴的package包/類
public void started(AbstractBuild build) {
CauseAction causeAction = build.getAction(CauseAction.class);
if (causeAction != null) {
Cause scmCause = causeAction.findCause(SCMTrigger.SCMTriggerCause.class);
if (scmCause == null) {
MessageBuilder message = new MessageBuilder(notifier, build);
message.append(causeAction.getShortDescription());
notifyStart(build, message.appendOpenLink().toString());
// Cause was found, exit early to prevent double-message
return;
}
}
String changes = getChanges(build, notifier.includeCustomMessage());
if (changes != null) {
notifyStart(build, changes);
} else {
notifyStart(build, getBuildStatusMessage(build, false, false,notifier.includeCustomMessage()));
}
}
示例13: getBuildStatusMessage
import hudson.model.AbstractBuild; //導入依賴的package包/類
String getBuildStatusMessage(AbstractBuild r, boolean includeTestSummary,boolean includeFailedTests, boolean includeCustomMessage) {
MessageBuilder message = new MessageBuilder(notifier, r);
message.appendStatusMessage();
message.appendDuration();
message.appendOpenLink();
if (includeTestSummary) {
message.appendTestSummary(includeFailedTests);
}
if (includeCustomMessage) {
message.appendCustomMessage();
}
if (notifier.getCommitInfoChoice().showAnything()){
message.appendCommitMessage(r);
}
return message.toString();
}
示例14: getStatusMessage
import hudson.model.AbstractBuild; //導入依賴的package包/類
@SuppressWarnings("Duplicates")
static String getStatusMessage(AbstractBuild r) {
MessageStatus status = getBuildStatus(r);
switch (status){
case STARTING:
return STARTING_STATUS_MESSAGE;
case BACK_TO_NORMAL:
return BACK_TO_NORMAL_STATUS_MESSAGE;
case STILL_FAILING:
return STILL_FAILING_STATUS_MESSAGE;
case SUCCESS:
return SUCCESS_STATUS_MESSAGE;
case FAILURE:
return FAILURE_STATUS_MESSAGE;
case ABORTED:
return ABORTED_STATUS_MESSAGE;
case UNSTABLE:
return UNSTABLE_STATUS_MESSAGE;
case NOT_BUILT:
return NOT_BUILT_STATUS_MESSAGE;
default:return UNKNOWN_STATUS_MESSAGE;
}
}
示例15: getStatusEmoticon
import hudson.model.AbstractBuild; //導入依賴的package包/類
@SuppressWarnings("Duplicates")
static String getStatusEmoticon(AbstractBuild r){
MessageStatus status = getBuildStatus(r);
switch (status){
case STARTING:
return STARTING_STATUS_EMOTICON;
case BACK_TO_NORMAL:
return BACK_TO_NORMAL_STATUS_EMOTICON;
case STILL_FAILING:
return STILL_FAILING_STATUS_EMOTICON;
case SUCCESS:
return SUCCESS_STATUS_EMOTICON;
case FAILURE:
return FAILURE_STATUS_EMOTICON;
case ABORTED:
return ABORTED_STATUS_EMOTICON;
case UNSTABLE:
return UNSTABLE_STATUS_EMOTICON;
case NOT_BUILT:
return NOT_BUILT_STATUS_EMOTICON;
default:return UNKNOWN_STATUS_EMOTICON;
}
}