Search in sources :

Example 11 with GiteaHook

use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.

the class MockGiteaConnection method createHook.

@Override
public GiteaHook createHook(GiteaOrganization organization, GiteaHook hook) throws IOException, InterruptedException {
    List<GiteaHook> list = notFoundIfNull(orgHooks.get(organization));
    hook = hook.clone();
    hook.setId(nextId.incrementAndGet());
    hook.setCreatedAt(new Date());
    hook.setUpdatedAt(hook.getCreatedAt());
    list.add(hook);
    return hook.clone();
}
Also used : GiteaHook(org.jenkinsci.plugin.gitea.client.api.GiteaHook) Date(java.util.Date)

Example 12 with GiteaHook

use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.

the class MockGiteaConnection method deleteHook.

@Override
public void deleteHook(GiteaOrganization organization, long id) throws IOException, InterruptedException {
    GiteaHook target = null;
    for (Iterator<GiteaHook> iterator = notFoundIfNull(orgHooks.get(organization)).iterator(); iterator.hasNext(); ) {
        GiteaHook h = iterator.next();
        if (h.getId() == id) {
            iterator.remove();
            target = h;
            break;
        }
    }
    notFoundIfNull(target);
}
Also used : GiteaHook(org.jenkinsci.plugin.gitea.client.api.GiteaHook)

Example 13 with GiteaHook

use of org.jenkinsci.plugin.gitea.client.api.GiteaHook in project gitea-plugin by jenkinsci.

the class DefaultGiteaConnection method updateHook.

@Override
public void updateHook(GiteaOrganization organization, GiteaHook hook) throws IOException, InterruptedException {
    GiteaHook diff = new GiteaHook();
    diff.setConfig(hook.getConfig());
    diff.setActive(hook.isActive());
    diff.setEvents(hook.getEvents());
    patch(api().literal("/orgs").path(UriTemplateBuilder.var("name")).literal("/hooks").path(UriTemplateBuilder.var("id")).build().set("name", organization.getUsername()).set("id", hook.getId()), diff, Void.class);
}
Also used : GiteaHook(org.jenkinsci.plugin.gitea.client.api.GiteaHook)

Aggregations

GiteaHook (org.jenkinsci.plugin.gitea.client.api.GiteaHook)13 Date (java.util.Date)5 JenkinsLocationConfiguration (jenkins.model.JenkinsLocationConfiguration)3 GiteaConnection (org.jenkinsci.plugin.gitea.client.api.GiteaConnection)3 GiteaEventType (org.jenkinsci.plugin.gitea.client.api.GiteaEventType)3 GiteaRepository (org.jenkinsci.plugin.gitea.client.api.GiteaRepository)3 GiteaServer (org.jenkinsci.plugin.gitea.servers.GiteaServer)3 StandardCredentials (com.cloudbees.plugins.credentials.common.StandardCredentials)2 IOException (java.io.IOException)2 GiteaOrganization (org.jenkinsci.plugin.gitea.client.api.GiteaOrganization)2 IgnoreNotifyCommit (hudson.plugins.git.extensions.impl.IgnoreNotifyCommit)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1