hudson.model.AbstractBuild Java Examples

The following examples show how to use hudson.model.AbstractBuild. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransitionTest.java    From jira-ext-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * An exception adding the first label add should not disrupt the next label
 */
@Test
public void testResiliency()
        throws Exception
{
    Transition transition = new Transition("Resolve");
    transition.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).changeWorkflowOfTicket("SSD-101", "Test Comment");
    transition.perform(jiraCommits, mockBuild, mock(Launcher.class), new StreamBuildListener(System.out, Charset.defaultCharset()));
    verify(jiraClientSvc, times(1)).changeWorkflowOfTicket(eq("SSD-101"), eq("Resolve"));
    verify(jiraClientSvc, times(1)).changeWorkflowOfTicket(eq("SSD-102"), eq("Resolve"));
}
 
Example #2
Source File: FlakyTestResultAction.java    From flaky-test-handler-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a FlakyTestResultAction object with Run and BuildListener
 *
 * @param build this build
 * @param listener listener of this build
 */
public FlakyTestResultAction(AbstractBuild build, Launcher launcher, TaskListener listener) throws IOException, InterruptedException {
  this.build = build;
  // TODO consider the possibility that there is >1 such action
  AbstractTestResultAction action = build.getAction(AbstractTestResultAction.class);
  if (action != null) {
    Object latestResult = action.getResult();
    if (latestResult != null && latestResult instanceof TestResult) {
      VirtualChannel channel = launcher.getChannel();
      if(channel == null) {
        throw new InterruptedException("Could not get channel to run a program remotely.");
      }
      FlakyTestResult flakyTestResult = channel.call(new FlakyTestResultCollector((TestResult) latestResult));

      flakyTestResult.freeze(action, build);
      FlakyRunStats stats = new FlakyRunStats(flakyTestResult.getTestFlakyStatsMap());
      setFlakyRunStats(stats, listener);
    }
  } else {
    logger.log(Level.WARNING, "No test result found, please publish junit report first");
  }
}
 
Example #3
Source File: JobStateRecipe.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Job<?, ?> get() {
    AbstractBuild earlierBuild, earliestBuild;

    // link "previous" builds ...
    while (buildHistory.size() > 1) {
        earliestBuild = buildHistory.pop();
        earlierBuild  = buildHistory.peek();

        when(earlierBuild.getPreviousBuild()).thenReturn(earliestBuild);
    }

    // pick the first build from the build history and make it the "last build"
    if (buildHistory.size() == 1) {
    	doReturn(buildHistory.pop()).when(job).getLastBuild();
    }
    
    // mock the necessary methods to get the currentBuilds
    // it will return the full list so make sure it contains only building builds
    doReturn(runList).when(job).getNewBuilds();
    doReturn(runList).when(runList).filter(any(Predicate.class));
    doReturn(allBuilds.iterator()).when(runList).iterator();

    return job;
}
 
Example #4
Source File: AddFixVersionTest.java    From jira-ext-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testExpandValues()
        throws Exception
{
    AddFixVersion addFixVersion = new AddFixVersion("Beta Release $FOO");
    addFixVersion.setJiraClientSvc(jiraClientSvc);
    AbstractBuild mockBuild = mock(AbstractBuild.class);
    EnvVars envVars = new EnvVars();
    envVars.put("FOO", "BAR");
    when(mockBuild.getEnvironment(any(TaskListener.class))).thenReturn(envVars);
    List<JiraCommit> jiraCommits = new ArrayList<>();
    jiraCommits.add(new JiraCommit("SSD-101"));
    jiraCommits.add(new JiraCommit("SSD-101"));

    addFixVersion.perform(jiraCommits, mockBuild, mock(Launcher.class), new StreamBuildListener(System.out, Charset.defaultCharset()));
    verify(jiraClientSvc, times(1)).addFixVersion(eq("SSD-101"), eq("Beta Release BAR"));

}
 
Example #5
Source File: BindingStep.java    From credentials-binding-plugin with MIT License 6 votes vote down vote up
@Override public OutputStream decorateLogger(AbstractBuild _ignore, final OutputStream logger) throws IOException, InterruptedException {
    final Pattern p = Pattern.compile(pattern.getPlainText());
    return new LineTransformationOutputStream() {
        @Override protected void eol(byte[] b, int len) throws IOException {
            if (!p.toString().isEmpty()) {
                Matcher m = p.matcher(new String(b, 0, len, charsetName));
                if (m.find()) {
                    logger.write(m.replaceAll("****").getBytes(charsetName));
                } else {
                    // Avoid byte → char → byte conversion unless we are actually doing something.
                    logger.write(b, 0, len);
                }
            } else {
                // Avoid byte → char → byte conversion unless we are actually doing something.
                logger.write(b, 0, len);
            }
        }
        @Override public void flush() throws IOException {
            logger.flush();
        }
        @Override public void close() throws IOException {
            super.close();
            logger.close();
        }
    };
}
 
Example #6
Source File: AnsibleAdHocCommandInvocationTest.java    From ansible-plugin with Apache License 2.0 6 votes vote down vote up
@Test
@Ignore("build.getWorkspace() cannot be mocked")
public void should_handle_private_key_credentials() throws Exception {
    // Given
    Inventory inventory = new InventoryPath("/tmp/hosts");
    SSHUserPrivateKey pkey = mock(SSHUserPrivateKey.class);
    when(pkey.getUsername()).thenReturn("mylogin");
    BuildListener listener = mock(BuildListener.class);
    CLIRunner runner = mock(CLIRunner.class);
    AbstractBuild<?,?> build = mock(AbstractBuild.class);
    when(build.getEnvironment(any(TaskListener.class))).thenReturn(new EnvVars());
    AnsibleAdHocCommandInvocation invocation = new AnsibleAdHocCommandInvocation("/usr/local/bin/ansible", build, listener);
    invocation.setHostPattern("localhost");
    invocation.setInventory(inventory);
    invocation.setModule("ping");
    invocation.setCredentials(pkey);
    invocation.setForks(5);
    // When
    invocation.execute(runner);
    // Then
    ArgumentCaptor<ArgumentListBuilder> argument = ArgumentCaptor.forClass(ArgumentListBuilder.class);
    verify(runner).execute(argument.capture(), anyMap());
    assertThat(argument.getValue().toString())
            .matches("/usr/local/bin/ansible localhost -i /tmp/hosts -m ping -f 5 --private-key .+ -u mylogin");
}
 
Example #7
Source File: AddFixVersion.java    From jira-ext-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void perform(List<JiraCommit> commits, AbstractBuild build, Launcher launcher, BuildListener listener)
{
    for (JiraCommit commit : JiraCommit.filterDuplicateIssues(commits))
    {
        try
        {
            String expandedFixVersion = build.getEnvironment(listener).expand(fixVersion);
            getJiraClientSvc().addFixVersion(commit.getJiraTicket(), expandedFixVersion);
        }
        catch (Throwable t)
        {
            listener.getLogger().println("ERROR Updating fix versions, skipping");
            t.printStackTrace(listener.getLogger());
        }
    }
}
 
Example #8
Source File: ExtractResourceWithChangesSCM.java    From jenkins-test-harness with MIT License 6 votes vote down vote up
@Override
public boolean checkout(AbstractBuild<?,?> build, Launcher launcher, FilePath workspace, BuildListener listener, File changeLogFile) throws IOException, InterruptedException {
    if (workspace.exists()) {
        listener.getLogger().println("Deleting existing workspace " + workspace.getRemote());
        workspace.deleteRecursive();
    }
    listener.getLogger().println("Staging first zip: " + firstZip);
    workspace.unzipFrom(firstZip.openStream());
    listener.getLogger().println("Staging second zip: " + secondZip);
    workspace.unzipFrom(secondZip.openStream());

    // Get list of files changed in secondZip.
    ExtractChangeLogParser.ExtractChangeLogEntry changeLog = new ExtractChangeLogParser.ExtractChangeLogEntry(secondZip.toString());

    try (ZipInputStream zip = new ZipInputStream(secondZip.openStream())) {
        ZipEntry e;
        while ((e = zip.getNextEntry()) != null) {
            if (!e.isDirectory())
                changeLog.addFile(new ExtractChangeLogParser.FileInZip(e.getName()));
        }
    }
    saveToChangeLog(changeLogFile, changeLog);

    return true;
}
 
Example #9
Source File: ZAProxy.java    From zaproxy-plugin with MIT License 6 votes vote down vote up
/**
 * Return the ZAProxy program name with separator prefix (\zap.bat or /zap.sh) depending of the build node and the OS.
 * 
 * @param build
 * @return the ZAProxy program name with separator prefix (\zap.bat or /zap.sh)
 * @throws IOException
 * @throws InterruptedException
 */
private String getZAPProgramNameWithSeparator(AbstractBuild<?, ?> build) throws IOException, InterruptedException {
	Node node = build.getBuiltOn();
	String zapProgramName = "";
	
	// Append zap program following Master/Slave and Windows/Unix
	if( "".equals(node.getNodeName())) { // Master
		if( File.pathSeparatorChar == ':' ) { // UNIX
			zapProgramName = "/" + ZAP_PROG_NAME_SH;
		} else { // Windows (pathSeparatorChar == ';')
			zapProgramName = "\\" + ZAP_PROG_NAME_BAT;
		}
	} 
	else { // Slave
		if( "Unix".equals(((SlaveComputer)node.toComputer()).getOSDescription()) ) {
			zapProgramName = "/" + ZAP_PROG_NAME_SH;
		} else {
			zapProgramName = "\\" + ZAP_PROG_NAME_BAT;
		}
	}
	return zapProgramName;
}
 
Example #10
Source File: EnvironmentTagBuilder.java    From jenkins-deployment-dashboard-plugin with MIT License 6 votes vote down vote up
/**
 * We'll use this from the <tt>config.jelly</tt>.
 */

@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
    DeployJobVariables jobVariables = extractDeployJobVariables(build);

    String message = region + " Tagging ENVIRONMENT [" + jobVariables.getEnvironment() + "] with VERSION [" + jobVariables.getVersion() + "]";
    listener.getLogger().println(message);

    EC2Connector connector = EC2Connector.getEC2Connector(getCredentials());
    boolean taggingSuccessful = connector.tagEnvironmentWithVersion(Region.getRegion(Regions.fromName(region)), jobVariables);
    if (!taggingSuccessful) {
        String failedMessage = "ERROR: Could not tag ENVIRONMENT [" + jobVariables.getEnvironment() + "] with VERSION [" + jobVariables.getVersion() + "]";
        listener.getLogger().println(failedMessage);
    }

    return taggingSuccessful;
}
 
Example #11
Source File: GithubBuildStatusGraphListenerTest.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
/**
 * Verifies onNewHead adds the build action for an atom node if there's an error (used for sending errors that occur
 * out of a stage
 */
@Test
public void testAtomNodeAddsAction() throws IOException {
    ErrorAction error = mock(ErrorAction.class);
    CpsFlowExecution execution = mock(CpsFlowExecution.class);
    StepAtomNode stageNode = new StepAtomNode(execution, null, mock(FlowNode.class));
    stageNode.addAction(error);

    FlowExecutionOwner owner = mock(FlowExecutionOwner.class);
    when(execution.getOwner()).thenReturn(owner);
    AbstractBuild build = mock(AbstractBuild.class);
    when(owner.getExecutable()).thenReturn(build);
    when(build.getAction(ExecutionModelAction.class)).thenReturn(null); // not declarative

    GithubBuildStatusGraphListener instance = new GithubBuildStatusGraphListener();
    instance.onNewHead(stageNode);
    verify(build).addAction(any(BuildStatusAction.class));
}
 
Example #12
Source File: CardBuilderTest.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    ItemGroup itemGroup = mock(ItemGroup.class);
    when(itemGroup.getFullDisplayName()).thenReturn(StringUtils.EMPTY);

    Job job = mock(Job.class);
    when(job.getDisplayName()).thenReturn(JOB_DISPLAY_NAME);
    when(job.getParent()).thenReturn(itemGroup);

    run = mock(AbstractBuild.class);
    when(run.getNumber()).thenReturn(BUILD_NUMBER);
    when(run.getParent()).thenReturn(job);

    mockDisplayURLProvider(JOB_DISPLAY_NAME, BUILD_NUMBER);
    TaskListener taskListener = mock(TaskListener.class);
    cardBuilder = new CardBuilder(run, taskListener);
}
 
Example #13
Source File: CardBuilderTest.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void getEscapedDisplayName_OnNameWithSpecialCharacters_EscapesSpecialCharacters() {

    // given
    final String specialDisplayName = "this_is_my-very#special *job*";
    ItemGroup itemGroup = mock(ItemGroup.class);
    when(itemGroup.getFullDisplayName()).thenReturn(StringUtils.EMPTY);

    Job job = mock(Job.class);
    when(job.getDisplayName()).thenReturn(specialDisplayName);
    when(job.getParent()).thenReturn(itemGroup);

    run = mock(AbstractBuild.class);
    when(run.getParent()).thenReturn(job);
    TaskListener taskListener = mock(TaskListener.class);

    mockDisplayURLProvider(JOB_DISPLAY_NAME, BUILD_NUMBER);
    cardBuilder = new CardBuilder(run, taskListener);

    // when
    String displayName = Deencapsulation.invoke(cardBuilder, "getEscapedDisplayName");

    // then
    assertThat(displayName).isEqualTo("this\\_is\\_my\\-very\\#special \\*job\\*");
}
 
Example #14
Source File: ExtractChangeLogParser.java    From jenkins-test-harness with MIT License 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public ExtractChangeLogSet parse(AbstractBuild build, File changeLogFile) throws IOException, SAXException {
    if (changeLogFile.exists()) {
        FileInputStream fis = new FileInputStream(changeLogFile);
        ExtractChangeLogSet logSet = parse(build, fis);
        fis.close();
        return logSet;
    } else {
        return new ExtractChangeLogSet(build, new ArrayList<ExtractChangeLogEntry>());
    }
}
 
Example #15
Source File: GitLabMessagePublisherTest.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private void performAndVerify(AbstractBuild build, String note, boolean onlyForFailure, boolean replaceSuccessNote, boolean replaceFailureNote, boolean replaceAbortNote, boolean replaceUnstableNote, HttpRequest... requests) throws InterruptedException, IOException {
    String successNoteText = replaceSuccessNote ? note : null;
    String failureNoteText = replaceFailureNote ? note : null;
    String abortNoteText = replaceAbortNote ? note : null;
    String unstableNoteText = replaceUnstableNote ? note : null;
    GitLabMessagePublisher publisher = preparePublisher(new GitLabMessagePublisher(onlyForFailure, replaceSuccessNote, replaceFailureNote, replaceAbortNote, replaceUnstableNote, successNoteText, failureNoteText, abortNoteText, unstableNoteText), build);
    publisher.perform(build, null, listener);

    if (requests.length > 0) {
        mockServerClient.verify(requests);
    } else {
        mockServerClient.verifyZeroInteractions();
    }
}
 
Example #16
Source File: WorkSpaceZipperTest.java    From aws-lambda-jenkins-plugin with MIT License 5 votes vote down vote up
@Test
public void testGetZipWithZip() throws Exception {
    final OneShotEvent buildEnded = new OneShotEvent();

    FreeStyleProject p = j.createFreeStyleProject();
    p.getBuildersList().add(new TestBuilder() {
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
                               BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("echo.zip").copyFrom(new FileInputStream(testUtil.getResource("echo.zip")));
            buildEnded.signal();
            return true;
        }
    });

    p.scheduleBuild2(0);
    buildEnded.block();

    JenkinsLogger logger = new JenkinsLogger(System.out);
    WorkSpaceZipper workSpaceZipper = new WorkSpaceZipper(p.getSomeWorkspace(), logger);
    File zip = workSpaceZipper.getZip("echo.zip");

    assertTrue(zip.exists());
    assertTrue(zip.getAbsolutePath().contains("awslambda-"));

    ZipFile zipFile = new ZipFile(zip);
    assertNotNull(zipFile);
    assertNotNull(zipFile.getEntry("index.js"));
}
 
Example #17
Source File: DockerServerEndpoint.java    From docker-commons-plugin with MIT License 5 votes vote down vote up
/**
 * Makes the key materials available locally for the on-going build
 * and returns {@link KeyMaterialFactory} that gives you the parameters needed to access it.
 *
 * @deprecated Call {@link #newKeyMaterialFactory(Run, VirtualChannel)}
 */
@Deprecated
public KeyMaterialFactory newKeyMaterialFactory(@Nonnull AbstractBuild build) throws IOException, InterruptedException {
    final FilePath workspace = build.getWorkspace();
    if (workspace == null) {
        throw new IllegalStateException("Build has no workspace");
    }
    return newKeyMaterialFactory(build, workspace.getChannel());
}
 
Example #18
Source File: SemanticVersioningBuilder.java    From semantic-versioning-plugin with MIT License 5 votes vote down vote up
private void writeVersionToFile(AbstractBuild<?,?> build, String reportedVersion) {
    String filename = build.getRootDir() + "/" + Messages.SEMANTIC_VERSION_FILENAME;
    File file = new File(filename);
    try {
        FileUtils.writeStringToFile(file, reportedVersion + "\n");
    } catch (IOException e) {
        System.out.println(e);
    }
}
 
Example #19
Source File: PhabricatorBuildWrapper.java    From phabricator-jenkins-plugin with MIT License 5 votes vote down vote up
/**
 * Abort running builds when new build referencing same revision is scheduled to run
 */
@Override
public void preCheckout(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException,
        InterruptedException {
    String abortOnRevisionId = getAbortOnRevisionId(build);
    // If ABORT_ON_REVISION_ID is available
    if (!CommonUtils.isBlank(abortOnRevisionId)) {
        // Create a cause of interruption
        PhabricatorCauseOfInterruption causeOfInterruption =
                new PhabricatorCauseOfInterruption(build.getUrl());
        Run upstreamRun = getUpstreamRun(build);

        // Get the running builds that were scheduled before the current one
        RunList<AbstractBuild> runningBuilds = (RunList<AbstractBuild>) build.getProject().getBuilds();
        for (AbstractBuild runningBuild : runningBuilds) {
            Executor executor = runningBuild.getExecutor();
            Run runningBuildUpstreamRun = getUpstreamRun(runningBuild);

            // Ignore builds that were triggered by the same upstream build
            // Find builds triggered with the same ABORT_ON_REVISION_ID_FIELD
            if (runningBuild.isBuilding()
                    && runningBuild.number < build.number
                    && abortOnRevisionId.equals(getAbortOnRevisionId(runningBuild))
                    && (upstreamRun == null
                    || runningBuildUpstreamRun == null
                    || !upstreamRun.equals(runningBuildUpstreamRun))
                    && executor != null) {
                // Abort the builds
                executor.interrupt(Result.ABORTED, causeOfInterruption);
            }
        }
    }
}
 
Example #20
Source File: DockerJobProperty.java    From docker-plugin with MIT License 5 votes vote down vote up
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    final Node node = build.getBuiltOn();
    if (!(node instanceof DockerTransientNode)) {
        return true;
    }
    DockerTransientNode dockerNode = (DockerTransientNode) node;
    final String containerId = dockerNode.getContainerId();
    final DockerAPI dockerAPI = dockerNode.getDockerAPI();
    try(final DockerClient client = dockerAPI.getClient()) {
        return perform(build, listener, containerId, dockerAPI, client);
    }
}
 
Example #21
Source File: PhabricatorBuildWrapper.java    From phabricator-jenkins-plugin with MIT License 5 votes vote down vote up
@VisibleForTesting
static String getAbortOnRevisionId(AbstractBuild build) {
    ParametersAction parameters = build.getAction(ParametersAction.class);
    if (parameters != null) {
        ParameterValue parameterValue = parameters.getParameter(
                PhabricatorPlugin.ABORT_ON_REVISION_ID_FIELD);
        if (parameterValue != null) {
            return (String) parameterValue.getValue();
        }
    }
    return null;
}
 
Example #22
Source File: TouchBuilder.java    From jenkins-test-harness with MIT License 5 votes vote down vote up
@Override
public boolean perform(AbstractBuild<?, ?> build,
                       Launcher launcher, BuildListener listener)
        throws InterruptedException, IOException {
    for (FilePath f : build.getWorkspace().list()) {
        f.touch(System.currentTimeMillis());
    }
    return true;
}
 
Example #23
Source File: ExecutionTest.java    From office-365-connector-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    run = mock(AbstractBuild.class);
    AbstractBuild previousBuild = mock(AbstractBuild.class);
    when(run.getPreviousBuild()).thenReturn(previousBuild);

    mockOffice365ConnectorWebhookNotifier();
}
 
Example #24
Source File: DockerJobProperty.java    From docker-plugin with MIT License 5 votes vote down vote up
private String getAdditionalTag(AbstractBuild build, TaskListener listener) {
    // Do a macro expansion on the addJenkinsAction token

    // Job property
    String tagToken = additionalTag;

    // Do any macro expansions
    try {
        if (!Strings.isNullOrEmpty(tagToken))
            tagToken = TokenMacro.expandAll(build, listener, tagToken);
    } catch (Exception e) {
        LOGGER.warn("can't expand macro", e);
    }
    return tagToken;
}
 
Example #25
Source File: AWSDeviceFarmTestResultAction.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * @return the most recent AWS Device Farm test action from the previous build
 */
@Override
public AWSDeviceFarmTestResultAction getPreviousResult() {
    AbstractBuild<?, ?> build = getOwner();
    if (owner == null) {
        return null;
    }
    return AWSDeviceFarmUtils.previousAWSDeviceFarmBuildAction(build.getProject());
}
 
Example #26
Source File: DockerBuilderControlOptionRun.java    From docker-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused")
private static String expand(Run<?, ?> build, String text) {
    try {
        if (build instanceof AbstractBuild && !Strings.isNullOrEmpty(text)) {
            return TokenMacro.expandAll((AbstractBuild) build, TaskListener.NULL, text);
        }
    } catch (Exception e) {
        LOG.info("Unable to expand variables in text {}", text);
    }
    return text;
}
 
Example #27
Source File: WorkspaceFileExporter.java    From DotCi with MIT License 5 votes vote down vote up
private FilePath getFilePath(final AbstractBuild<?, ?> build) {
    final FilePath ws = build.getWorkspace();
    if (ws == null) {
        final Node node = build.getBuiltOn();
        if (node == null) {
            throw new RuntimeException("no such build node: " + build.getBuiltOnStr());
        }
        throw new RuntimeException("no workspace from node " + node + " which is computer " + node.toComputer() + " and has channel " + node.getChannel());
    }
    return ws;
}
 
Example #28
Source File: TestObject.java    From junit-plugin with MIT License 5 votes vote down vote up
@Deprecated
public AbstractBuild<?,?> getOwner() {
    if (Util.isOverridden(TestObject.class, getClass(), "getRun")) {
        Run<?,?> r = getRun();
        return r instanceof AbstractBuild ? (AbstractBuild) r : null;
    } else {
        throw new AbstractMethodError("you must override getRun");
    }
}
 
Example #29
Source File: GitLabCommitStatusPublisherTest.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void unstable() throws IOException, InterruptedException {
    AbstractBuild build = mockBuild(GITLAB_CONNECTION_V4, Result.UNSTABLE, "test/project.git");
    HttpRequest[] requests = prepareCheckCommitAndUpdateStatusRequests("v4", build, BuildState.failed);

    performAndVerify(build, false, requests);
}
 
Example #30
Source File: FlakyCaseResult.java    From flaky-test-handler-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public AbstractBuild<?,?> getOwner() {
  FlakySuiteResult sr = getSuiteResult();
  if (sr==null) {
    LOGGER.warning("In getOwner(), getSuiteResult is null"); return null; }
  FlakyTestResult tr = sr.getParent();
  if (tr==null) {
    LOGGER.warning("In getOwner(), suiteResult.getParent() is null."); return null; }
  return tr.getOwner();
}