Search in sources :

Example 1 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(GiteaRepository repository, GiteaHook hook) throws IOException, InterruptedException {
    GiteaHook diff = new GiteaHook();
    diff.setConfig(hook.getConfig());
    diff.setActive(hook.isActive());
    diff.setEvents(hook.getEvents());
    patch(api().literal("/repos").path(UriTemplateBuilder.var("username")).path(UriTemplateBuilder.var("name")).literal("/hooks").path(UriTemplateBuilder.var("id")).build().set("username", repository.getOwner().getUsername()).set("name", repository.getName()).set("id", hook.getId()), diff, Void.class);
}
Also used : GiteaHook(org.jenkinsci.plugin.gitea.client.api.GiteaHook)

Example 2 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(GiteaRepository repository, long id) throws IOException, InterruptedException {
    GiteaHook target = null;
    for (Iterator<GiteaHook> iterator = notFoundIfNull(repoHooks.get(keyOf(repository))).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 3 with GiteaHook

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

the class MockGiteaConnection method withRepo.

public MockGiteaConnection withRepo(GiteaRepository repo) {
    GiteaRepository clone = repo.clone();
    clone.setId(nextId.incrementAndGet());
    clone.setCreatedAt(new Date());
    clone.setUpdatedAt(new Date());
    this.repositories.put(keyOf(clone), clone);
    this.repoHooks.put(keyOf(clone), new ArrayList<GiteaHook>());
    this.branches.put(keyOf(clone), new HashMap<String, GiteaBranch>());
    this.pulls.put(keyOf(clone), new HashMap<Long, GiteaPullRequest>());
    this.issues.put(keyOf(clone), new HashMap<Long, GiteaIssue>());
    this.collaborators.put(keyOf(clone), new TreeSet<String>());
    this.files.put(keyOf(clone), new TreeMap<String, Map<String, byte[]>>());
    return this;
}
Also used : GiteaIssue(org.jenkinsci.plugin.gitea.client.api.GiteaIssue) GiteaBranch(org.jenkinsci.plugin.gitea.client.api.GiteaBranch) GiteaHook(org.jenkinsci.plugin.gitea.client.api.GiteaHook) Date(java.util.Date) AtomicLong(java.util.concurrent.atomic.AtomicLong) GiteaPullRequest(org.jenkinsci.plugin.gitea.client.api.GiteaPullRequest) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) GiteaRepository(org.jenkinsci.plugin.gitea.client.api.GiteaRepository)

Example 4 with GiteaHook

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

the class MockGiteaConnection method withOrg.

public MockGiteaConnection withOrg(GiteaOrganization org) {
    GiteaOrganization clone = org.clone();
    clone.setId(nextId.incrementAndGet());
    this.organizations.put(org.getUsername(), clone);
    this.orgHooks.put(org.getUsername(), new ArrayList<GiteaHook>());
    return this;
}
Also used : GiteaOrganization(org.jenkinsci.plugin.gitea.client.api.GiteaOrganization) GiteaHook(org.jenkinsci.plugin.gitea.client.api.GiteaHook)

Example 5 with GiteaHook

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

the class MockGiteaConnection method updateHook.

@Override
public void updateHook(GiteaOrganization organization, GiteaHook hook) throws IOException, InterruptedException {
    GiteaHook target = null;
    for (Iterator<GiteaHook> iterator = notFoundIfNull(orgHooks.get(organization)).iterator(); iterator.hasNext(); ) {
        GiteaHook h = iterator.next();
        if (h.getId() == hook.getId()) {
            target = h;
            break;
        }
    }
    notFoundIfNull(target);
    target.setUpdatedAt(new Date());
    target.setEvents(hook.getEvents());
    target.setActive(hook.isActive());
    target.setConfig(hook.getConfig());
}
Also used : GiteaHook(org.jenkinsci.plugin.gitea.client.api.GiteaHook) Date(java.util.Date)

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