Search in sources :

Example 1 with MessagingProviderOverrides

use of com.redhat.jenkins.plugins.ci.messaging.MessagingProviderOverrides in project jms-messaging-plugin by jenkinsci.

the class FedMsgMessagingPluginIntegrationTest method testTriggeringUsingFedMsgLogger.

@Test
public void testTriggeringUsingFedMsgLogger() throws Exception {
    FreeStyleProject jobA = j.createFreeStyleProject();
    jobA.getBuildersList().add(new Shell("echo CI_MESSAGE = $CI_MESSAGE"));
    attachTrigger(new CIBuildTrigger(true, Collections.singletonList(new FedMsgSubscriberProviderData("test", new MessagingProviderOverrides("org.fedoraproject.dev.logger.log"), Collections.singletonList(new MsgCheck("compose", ".+compose_id.+message.+")), "CI_MESSAGE", 60))), jobA);
    // Allow for connection
    Thread.sleep(5000);
    File privateKey = File.createTempFile("ssh", "key");
    FileUtils.copyURLToFile(FedmsgRelayContainer.class.getResource("FedmsgRelayContainer/unsafe"), privateKey);
    Files.setPosixFilePermissions(privateKey.toPath(), singleton(OWNER_READ));
    File ssh = File.createTempFile("jenkins", "ssh");
    FileUtils.writeStringToFile(ssh, "#!/bin/sh\n" + "exec ssh -o StrictHostKeyChecking=no -i " + privateKey.getAbsolutePath() + " fedmsg2@" + fedmsgRelay.getSshIPAndPort() + " fedmsg-logger " + " \"$@\"");
    Files.setPosixFilePermissions(ssh.toPath(), new HashSet<>(Arrays.asList(OWNER_READ, OWNER_EXECUTE)));
    System.out.println(FileUtils.readFileToString(ssh));
    ProcessBuilder gitLog1Pb = new ProcessBuilder(ssh.getAbsolutePath(), "--message='{\"compose\": " + "{\"compose_id\": \"This is a message.\"}}'", "--json-input");
    String output = stringFrom(logProcessBuilderIssues(gitLog1Pb, "ssh"));
    System.out.println(output);
    Thread.sleep(2000);
    waitUntilScheduledBuildCompletes();
    j.assertBuildStatusSuccess(jobA.getLastBuild());
    j.assertLogContains("This is a message", jobA.getLastBuild());
}
Also used : Shell(hudson.tasks.Shell) FedMsgSubscriberProviderData(com.redhat.jenkins.plugins.ci.provider.data.FedMsgSubscriberProviderData) CIBuildTrigger(com.redhat.jenkins.plugins.ci.CIBuildTrigger) FedmsgRelayContainer(com.redhat.jenkins.plugins.ci.integration.fixtures.FedmsgRelayContainer) FreeStyleProject(hudson.model.FreeStyleProject) MessagingProviderOverrides(com.redhat.jenkins.plugins.ci.messaging.MessagingProviderOverrides) MsgCheck(com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck) File(java.io.File) Test(org.junit.Test)

Aggregations

CIBuildTrigger (com.redhat.jenkins.plugins.ci.CIBuildTrigger)1 FedmsgRelayContainer (com.redhat.jenkins.plugins.ci.integration.fixtures.FedmsgRelayContainer)1 MessagingProviderOverrides (com.redhat.jenkins.plugins.ci.messaging.MessagingProviderOverrides)1 MsgCheck (com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck)1 FedMsgSubscriberProviderData (com.redhat.jenkins.plugins.ci.provider.data.FedMsgSubscriberProviderData)1 FreeStyleProject (hudson.model.FreeStyleProject)1 Shell (hudson.tasks.Shell)1 File (java.io.File)1 Test (org.junit.Test)1