18 | * Launches migration from old config versions
19 | * Contains helper method to get global plugin configuration - {@link #configuration()}
20 | *
21 | * @author lanwen (Merkushev Kirill)
22 | */
23 | public class GitHubPlugin extends Plugin {
24 | /**
25 | * Launched before plugin starts
26 | * Adds alias for {@link GitHubPlugin} to simplify resulting xml.
27 | */
28 | @Initializer(before = InitMilestone.SYSTEM_CONFIG_LOADED)
29 | @Restricted(DoNotUse.class)
30 | public static void addXStreamAliases() {
31 | Migrator.enableCompatibilityAliases();
32 | Migrator.enableAliases();
33 | }
34 |
35 | /**
36 | * Launches migration after all extensions have been augmented as we need to ensure that the credentials plugin
37 | * has been initialized.
38 | * We need ensure that migrator will run after xstream aliases will be added.
39 | * @see JENKINS-36446
40 | */
41 | @Initializer(after = InitMilestone.EXTENSIONS_AUGMENTED, before = InitMilestone.JOB_LOADED)
42 | public static void runMigrator() throws Exception {
43 | new Migrator().migrate();
44 | }
45 |
46 | /**
47 | * Shortcut method for getting instance of {@link GitHubPluginConfig}.
48 | *
49 | * @return configuration of plugin
50 | */
51 | @NonNull
52 | public static GitHubPluginConfig configuration() {
53 | return defaultIfNull(
54 | GitHubPluginConfig.all().get(GitHubPluginConfig.class),
55 | GitHubPluginConfig.EMPTY_CONFIG
56 | );
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/admin/GHRepoName.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.admin;
2 |
3 | import com.cloudbees.jenkins.GitHubRepositoryName;
4 | import org.kohsuke.stapler.AnnotationHandler;
5 | import org.kohsuke.stapler.InjectedParameter;
6 | import org.kohsuke.stapler.StaplerRequest2;
7 | import org.slf4j.Logger;
8 |
9 | import java.lang.annotation.Documented;
10 | import java.lang.annotation.Retention;
11 | import java.lang.annotation.Target;
12 |
13 | import static java.lang.annotation.ElementType.PARAMETER;
14 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
15 | import static org.apache.commons.lang3.Validate.notNull;
16 | import static org.slf4j.LoggerFactory.getLogger;
17 |
18 | /**
19 | * InjectedParameter annotation to use on WebMethod parameters.
20 | * Converts form submission to {@link GitHubRepositoryName}
21 | *
22 | * @author lanwen (Merkushev Kirill)
23 | * @see Web Method
24 | * @since 1.17.0
25 | */
26 | @Retention(RUNTIME)
27 | @Target(PARAMETER)
28 | @Documented
29 | @InjectedParameter(GHRepoName.PayloadHandler.class)
30 | public @interface GHRepoName {
31 | class PayloadHandler extends AnnotationHandler {
32 | private static final Logger LOGGER = getLogger(PayloadHandler.class);
33 |
34 | /**
35 | * @param param name of param in form and name of the argument in web-method
36 | *
37 | * @return {@link GitHubRepositoryName} extracted from request or null on any problem
38 | */
39 | @Override
40 | public GitHubRepositoryName parse(StaplerRequest2 req, GHRepoName a, Class type, String param) {
41 | String repo = notNull(req, "Why StaplerRequest2 is null?").getParameter(param);
42 | LOGGER.trace("Repo url in method {}", repo);
43 | return GitHubRepositoryName.create(repo);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/admin/RequireAdminRights.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.admin;
2 |
3 | import jenkins.model.Jenkins;
4 | import org.kohsuke.stapler.StaplerRequest2;
5 | import org.kohsuke.stapler.StaplerResponse2;
6 | import org.kohsuke.stapler.interceptor.Interceptor;
7 | import org.kohsuke.stapler.interceptor.InterceptorAnnotation;
8 |
9 | import jakarta.servlet.ServletException;
10 | import java.lang.annotation.Retention;
11 | import java.lang.annotation.Target;
12 | import java.lang.reflect.InvocationTargetException;
13 |
14 | import static java.lang.annotation.ElementType.FIELD;
15 | import static java.lang.annotation.ElementType.METHOD;
16 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
17 |
18 | /**
19 | * InterceptorAnnotation annotation to use on WebMethod signature.
20 | * Encapsulates preprocess logic of checking for admin rights
21 | *
22 | * @author lanwen (Merkushev Kirill)
23 | * @see Web Method
24 | */
25 | @Retention(RUNTIME)
26 | @Target({METHOD, FIELD})
27 | @InterceptorAnnotation(RequireAdminRights.Processor.class)
28 | public @interface RequireAdminRights {
29 | class Processor extends Interceptor {
30 |
31 | @Override
32 | public Object invoke(StaplerRequest2 request, StaplerResponse2 response, Object instance, Object[] arguments)
33 | throws IllegalAccessException, InvocationTargetException, ServletException {
34 |
35 | Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
36 | return target.invoke(request, response, instance, arguments);
37 | }
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/admin/RespondWithRedirect.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.admin;
2 |
3 | import org.kohsuke.stapler.HttpRedirect;
4 | import org.kohsuke.stapler.StaplerRequest2;
5 | import org.kohsuke.stapler.StaplerResponse2;
6 | import org.kohsuke.stapler.interceptor.Interceptor;
7 | import org.kohsuke.stapler.interceptor.InterceptorAnnotation;
8 |
9 | import jakarta.servlet.ServletException;
10 | import java.lang.annotation.Retention;
11 | import java.lang.annotation.Target;
12 | import java.lang.reflect.InvocationTargetException;
13 |
14 | import static java.lang.annotation.ElementType.FIELD;
15 | import static java.lang.annotation.ElementType.METHOD;
16 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
17 |
18 | /**
19 | * InterceptorAnnotation annotation to use on WebMethod signature.
20 | * Helps to redirect to prev page after web-method invoking.
21 | * WebMethod can return {@code void}
22 | *
23 | * @author lanwen (Merkushev Kirill)
24 | * @see Web Method
25 | */
26 | @Retention(RUNTIME)
27 | @Target({METHOD, FIELD})
28 | @InterceptorAnnotation(RespondWithRedirect.Processor.class)
29 | public @interface RespondWithRedirect {
30 | class Processor extends Interceptor {
31 |
32 | @Override
33 | public Object invoke(StaplerRequest2 request, StaplerResponse2 response, Object instance, Object[] arguments)
34 | throws IllegalAccessException, InvocationTargetException, ServletException {
35 | target.invoke(request, response, instance, arguments);
36 | throw new InvocationTargetException(new HttpRedirect("."));
37 | }
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/admin/ValidateRepoName.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.admin;
2 |
3 | import com.cloudbees.jenkins.GitHubRepositoryName;
4 | import org.kohsuke.stapler.StaplerRequest2;
5 | import org.kohsuke.stapler.StaplerResponse2;
6 | import org.kohsuke.stapler.interceptor.Interceptor;
7 | import org.kohsuke.stapler.interceptor.InterceptorAnnotation;
8 |
9 | import jakarta.servlet.ServletException;
10 | import java.lang.annotation.Retention;
11 | import java.lang.annotation.Target;
12 | import java.lang.reflect.InvocationTargetException;
13 |
14 | import static com.google.common.base.Predicates.instanceOf;
15 | import static com.google.common.collect.Lists.newArrayList;
16 | import static java.lang.annotation.ElementType.FIELD;
17 | import static java.lang.annotation.ElementType.METHOD;
18 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
19 | import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
20 | import static org.jenkinsci.plugins.github.util.FluentIterableWrapper.from;
21 | import static org.kohsuke.stapler.HttpResponses.errorWithoutStack;
22 |
23 | /**
24 | * InterceptorAnnotation annotation to use on WebMethod signature.
25 | * Encapsulates preprocess logic. Checks that arg list contains nonnull repo name object
26 | *
27 | * @author lanwen (Merkushev Kirill)
28 | * @see Web Method
29 | */
30 | @Retention(RUNTIME)
31 | @Target({METHOD, FIELD})
32 | @InterceptorAnnotation(ValidateRepoName.Processor.class)
33 | public @interface ValidateRepoName {
34 | class Processor extends Interceptor {
35 |
36 | @Override
37 | public Object invoke(StaplerRequest2 request, StaplerResponse2 response, Object instance, Object[] arguments)
38 | throws IllegalAccessException, InvocationTargetException, ServletException {
39 |
40 | if (!from(newArrayList(arguments)).firstMatch(instanceOf(GitHubRepositoryName.class)).isPresent()) {
41 | throw new InvocationTargetException(
42 | errorWithoutStack(SC_BAD_REQUEST, "Request should contain full repo name")
43 | );
44 | }
45 |
46 | return target.invoke(request, response, instance, arguments);
47 | }
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/common/CombineErrorHandler.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.common;
2 |
3 | import hudson.model.Run;
4 | import hudson.model.TaskListener;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import edu.umd.cs.findbugs.annotations.NonNull;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
13 |
14 | /**
15 | * With help of list of other error handlers handles exception.
16 | * If no one will handle it, exception will be wrapped to {@link ErrorHandlingException}
17 | * and thrown by the handle method
18 | *
19 | * @author lanwen (Merkushev Kirill)
20 | * @since 1.19.0
21 | */
22 | public class CombineErrorHandler implements ErrorHandler {
23 | private static final Logger LOG = LoggerFactory.getLogger(CombineErrorHandler.class);
24 |
25 | private List handlers = new ArrayList<>();
26 |
27 | private CombineErrorHandler() {
28 | }
29 |
30 | /**
31 | * Static factory to produce new instance of this handler
32 | *
33 | * @return new instance
34 | */
35 | public static CombineErrorHandler errorHandling() {
36 | return new CombineErrorHandler();
37 | }
38 |
39 | public CombineErrorHandler withHandlers(List extends ErrorHandler> handlers) {
40 | if (isNotEmpty(handlers)) {
41 | this.handlers.addAll(handlers);
42 | }
43 | return this;
44 | }
45 |
46 | /**
47 | * Handles exception with help of other handlers. If no one will handle it, it will be thrown to the top level
48 | *
49 | * @param e exception to handle (log, ignore, process, rethrow)
50 | * @param run run object from the step
51 | * @param listener listener object from the step
52 | *
53 | * @return true if exception handled or rethrows it
54 | */
55 | @Override
56 | public boolean handle(Exception e, @NonNull Run, ?> run, @NonNull TaskListener listener) {
57 | LOG.debug("Exception in {} will be processed with {} handlers",
58 | run.getParent().getName(), handlers.size(), e);
59 | try {
60 | for (ErrorHandler next : handlers) {
61 | if (next.handle(e, run, listener)) {
62 | LOG.debug("Exception in {} [{}] handled by [{}]",
63 | run.getParent().getName(),
64 | e.getMessage(),
65 | next.getClass());
66 | return true;
67 | }
68 | }
69 | } catch (Exception unhandled) {
70 | LOG.error("Exception in {} unhandled", run.getParent().getName(), unhandled);
71 | throw new ErrorHandlingException(unhandled);
72 | }
73 |
74 | throw new ErrorHandlingException(e);
75 | }
76 |
77 | /**
78 | * Wrapper for the not handled by this handler exceptions
79 | */
80 | public static class ErrorHandlingException extends RuntimeException {
81 | public ErrorHandlingException(Throwable cause) {
82 | super(cause);
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/common/ErrorHandler.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.common;
2 |
3 | import hudson.model.Run;
4 | import hudson.model.TaskListener;
5 |
6 | import edu.umd.cs.findbugs.annotations.NonNull;
7 |
8 | /**
9 | * So you can implement bunch of {@link ErrorHandler}s and log, rethrow, ignore exception.
10 | * Useful to control own step exceptions
11 | * (for example {@link org.jenkinsci.plugins.github.status.GitHubCommitStatusSetter})
12 | *
13 | * @author lanwen (Merkushev Kirill)
14 | * @since 1.19.0
15 | */
16 | public interface ErrorHandler {
17 |
18 | /**
19 | * Normally should return true if exception is handled and no other handler should do anything.
20 | * If you will return false, the next error handler should try to handle this exception
21 | *
22 | * @param e exception to handle (log, ignore, process, rethrow)
23 | * @param run run object from the step
24 | * @param listener listener object from the step
25 | *
26 | * @return true if exception handled successfully
27 | * @throws Exception you can rethrow exception of any type
28 | */
29 | boolean handle(Exception e, @NonNull Run, ?> run, @NonNull TaskListener listener) throws Exception;
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/extension/GHSubscriberEvent.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension;
2 |
3 | import jakarta.servlet.http.HttpServletRequest;
4 | import jenkins.scm.api.SCMEvent;
5 | import org.kohsuke.github.GHEvent;
6 |
7 | import edu.umd.cs.findbugs.annotations.CheckForNull;
8 | import edu.umd.cs.findbugs.annotations.NonNull;
9 |
10 | /**
11 | * An event for a {@link GHEventsSubscriber}.
12 | *
13 | * @since 1.26.0
14 | */
15 | public class GHSubscriberEvent extends SCMEvent {
16 | /**
17 | * The type of event.
18 | */
19 | private final GHEvent ghEvent;
20 |
21 | private final String eventGuid;
22 |
23 | /**
24 | * @deprecated use {@link #GHSubscriberEvent(String, String, GHEvent, String)} instead.
25 | */
26 | @Deprecated
27 | public GHSubscriberEvent(@CheckForNull String origin, @NonNull GHEvent ghEvent, @NonNull String payload) {
28 | this(null, origin, ghEvent, payload);
29 | }
30 |
31 | /**
32 | * Constructs a new {@link GHSubscriberEvent}.
33 | * @param eventGuid the globally unique identifier (GUID) to identify the event; value of
34 | * request header {@link com.cloudbees.jenkins.GitHubWebHook#X_GITHUB_DELIVERY}.
35 | * @param origin the origin (see {@link SCMEvent#originOf(HttpServletRequest)}) or {@code null}.
36 | * @param ghEvent the type of event received from GitHub.
37 | * @param payload the event payload.
38 | */
39 | public GHSubscriberEvent(
40 | @CheckForNull String eventGuid,
41 | @CheckForNull String origin,
42 | @NonNull GHEvent ghEvent,
43 | @NonNull String payload) {
44 | super(Type.UPDATED, payload, origin);
45 | this.ghEvent = ghEvent;
46 | this.eventGuid = eventGuid;
47 | }
48 |
49 | /**
50 | * Gets the type of event received.
51 | *
52 | * @return the type of event received.
53 | */
54 | public GHEvent getGHEvent() {
55 | return ghEvent;
56 | }
57 |
58 | @CheckForNull
59 | public String getEventGuid() {
60 | return eventGuid;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/extension/status/GitHubCommitShaSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension.status;
2 |
3 | import hudson.ExtensionPoint;
4 | import hudson.model.AbstractDescribableImpl;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 |
8 | import edu.umd.cs.findbugs.annotations.NonNull;
9 | import java.io.IOException;
10 |
11 | /**
12 | * Extension point to provide commit sha which will be used to set state
13 | *
14 | * @author lanwen (Merkushev Kirill)
15 | * @since 1.19.0
16 | */
17 | public abstract class GitHubCommitShaSource extends AbstractDescribableImpl
18 | implements ExtensionPoint {
19 |
20 | /**
21 | * @param run enclosing run
22 | * @param listener listener of the run. Can be used to fetch env vars
23 | *
24 | * @return plain sha to set state
25 | */
26 | public abstract String get(@NonNull Run, ?> run, @NonNull TaskListener listener)
27 | throws IOException, InterruptedException;
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/extension/status/GitHubReposSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension.status;
2 |
3 | import hudson.ExtensionPoint;
4 | import hudson.model.AbstractDescribableImpl;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.kohsuke.github.GHRepository;
8 |
9 | import edu.umd.cs.findbugs.annotations.NonNull;
10 | import java.util.List;
11 |
12 | /**
13 | * Extension point to provide list of resolved repositories where commit is located
14 | *
15 | * @author lanwen (Merkushev Kirill)
16 | * @since 1.19.0
17 | */
18 | public abstract class GitHubReposSource extends AbstractDescribableImpl implements ExtensionPoint {
19 |
20 | /**
21 | * @param run actual run
22 | * @param listener build listener
23 | *
24 | * @return resolved list of GitHub repositories
25 | */
26 | public abstract List repos(@NonNull Run, ?> run, @NonNull TaskListener listener);
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/extension/status/GitHubStatusBackrefSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension.status;
2 |
3 | import hudson.ExtensionPoint;
4 | import hudson.model.AbstractDescribableImpl;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 |
8 | /**
9 | * Extension point to provide backref for the status, i.e. to the build or to the test report.
10 | *
11 | * @author pupssman (Kalinin Ivan)
12 | * @since 1.21.2
13 | */
14 | public abstract class GitHubStatusBackrefSource extends AbstractDescribableImpl
15 | implements ExtensionPoint {
16 |
17 | /**
18 | * @param run actual run
19 | * @param listener build listener
20 | *
21 | * @return URL that points to the status source, i.e. test result page
22 | */
23 | public abstract String get(Run, ?> run, TaskListener listener);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/extension/status/GitHubStatusContextSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension.status;
2 |
3 | import hudson.ExtensionPoint;
4 | import hudson.model.AbstractDescribableImpl;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 |
8 | import edu.umd.cs.findbugs.annotations.NonNull;
9 |
10 | /**
11 | * Extension point to provide context of the state. For example `integration-tests` or `build`
12 | *
13 | * @author lanwen (Merkushev Kirill)
14 | * @since 1.19.0
15 | */
16 | public abstract class GitHubStatusContextSource extends AbstractDescribableImpl
17 | implements ExtensionPoint {
18 |
19 | /**
20 | * @param run actual run
21 | * @param listener build listener
22 | *
23 | * @return simple short string to represent context of this state
24 | */
25 | public abstract String context(@NonNull Run, ?> run, @NonNull TaskListener listener);
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/extension/status/GitHubStatusResultSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension.status;
2 |
3 | import hudson.ExtensionPoint;
4 | import hudson.model.AbstractDescribableImpl;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.kohsuke.github.GHCommitState;
8 |
9 | import edu.umd.cs.findbugs.annotations.NonNull;
10 | import java.io.IOException;
11 |
12 | /**
13 | * Extension point to provide exact state and message for the commit
14 | *
15 | * @author lanwen (Merkushev Kirill)
16 | * @since 1.19.0
17 | */
18 | public abstract class GitHubStatusResultSource extends AbstractDescribableImpl
19 | implements ExtensionPoint {
20 |
21 | /**
22 | * @param run actual run
23 | * @param listener run listener
24 | *
25 | * @return bean with state and already expanded message
26 | */
27 | public abstract StatusResult get(@NonNull Run, ?> run, @NonNull TaskListener listener)
28 | throws IOException, InterruptedException;
29 |
30 | /**
31 | * Bean with state and msg info
32 | */
33 | public static class StatusResult {
34 | private GHCommitState state;
35 | private String msg;
36 |
37 | public StatusResult(GHCommitState state, String msg) {
38 | this.state = state;
39 | this.msg = msg;
40 | }
41 |
42 | public GHCommitState getState() {
43 | return state;
44 | }
45 |
46 | public String getMsg() {
47 | return msg;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/extension/status/StatusErrorHandler.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension.status;
2 |
3 | import hudson.DescriptorExtensionList;
4 | import hudson.ExtensionPoint;
5 | import hudson.model.AbstractDescribableImpl;
6 | import hudson.model.Descriptor;
7 | import jenkins.model.Jenkins;
8 | import org.jenkinsci.plugins.github.common.ErrorHandler;
9 |
10 | /**
11 | * Extension point to provide way of how to react on errors in status setter step
12 | *
13 | * @author lanwen (Merkushev Kirill)
14 | * @since 1.19.0
15 | */
16 | public abstract class StatusErrorHandler extends AbstractDescribableImpl
17 | implements ErrorHandler, ExtensionPoint {
18 |
19 | /**
20 | * Used in view
21 | *
22 | * @return all of the available error handlers.
23 | */
24 | public static DescriptorExtensionList> all() {
25 | return Jenkins.getInstance().getDescriptorList(StatusErrorHandler.class);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/extension/status/misc/ConditionalResult.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension.status.misc;
2 |
3 | import hudson.DescriptorExtensionList;
4 | import hudson.ExtensionPoint;
5 | import hudson.model.AbstractDescribableImpl;
6 | import hudson.model.Descriptor;
7 | import hudson.model.Run;
8 | import hudson.util.ListBoxModel;
9 | import jenkins.model.Jenkins;
10 | import org.kohsuke.github.GHCommitState;
11 | import org.kohsuke.stapler.DataBoundSetter;
12 |
13 | import edu.umd.cs.findbugs.annotations.NonNull;
14 |
15 | /**
16 | * This extension point allows to define when and what to send as state and message.
17 | * It will be used as part of {@link org.jenkinsci.plugins.github.status.sources.ConditionalStatusResultSource}.
18 | *
19 | * @author lanwen (Merkushev Kirill)
20 | * @see org.jenkinsci.plugins.github.status.sources.misc.BetterThanOrEqualBuildResult
21 | * @since 1.19.0
22 | */
23 | public abstract class ConditionalResult extends AbstractDescribableImpl implements ExtensionPoint {
24 |
25 | private String state;
26 | private String message;
27 |
28 | @DataBoundSetter
29 | public void setState(String state) {
30 | this.state = state;
31 | }
32 |
33 | @DataBoundSetter
34 | public void setMessage(String message) {
35 | this.message = message;
36 | }
37 |
38 | /**
39 | * @return State to set. Will be converted to {@link GHCommitState}
40 | */
41 | public String getState() {
42 | return state;
43 | }
44 |
45 | /**
46 | * @return Message to write. Can contain env vars, will be expanded.
47 | */
48 | public String getMessage() {
49 | return message;
50 | }
51 |
52 | /**
53 | * If matches, will be used to set state
54 | *
55 | * @param run to check against
56 | *
57 | * @return true if matches
58 | */
59 | public abstract boolean matches(@NonNull Run, ?> run);
60 |
61 | /**
62 | * Should be extended to and marked as {@link hudson.Extension} to be in list
63 | */
64 | public abstract static class ConditionalResultDescriptor extends Descriptor {
65 |
66 | /**
67 | * Gets all available extensions. Used in view
68 | *
69 | * @return all descriptors of conditional results
70 | */
71 | public static DescriptorExtensionList> all() {
72 | return Jenkins.getInstance().getDescriptorList(ConditionalResult.class);
73 | }
74 |
75 | /**
76 | * @return options to fill state items in view
77 | */
78 | public ListBoxModel doFillStateItems() {
79 | ListBoxModel items = new ListBoxModel();
80 | for (GHCommitState commitState : GHCommitState.values()) {
81 | items.add(commitState.name());
82 | }
83 | return items;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/internal/GHPluginConfigException.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.internal;
2 |
3 | /**
4 | * @author lanwen (Merkushev Kirill)
5 | */
6 | public class GHPluginConfigException extends RuntimeException {
7 | public GHPluginConfigException(String message, Object... args) {
8 | super(String.format(message, args));
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/err/ChangingBuildStatusErrorHandler.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.err;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Descriptor;
5 | import hudson.model.Result;
6 | import hudson.model.Run;
7 | import hudson.model.TaskListener;
8 | import hudson.util.ListBoxModel;
9 | import org.jenkinsci.plugins.github.extension.status.StatusErrorHandler;
10 | import org.kohsuke.stapler.DataBoundConstructor;
11 |
12 | import edu.umd.cs.findbugs.annotations.NonNull;
13 |
14 | import static hudson.model.Result.FAILURE;
15 | import static hudson.model.Result.UNSTABLE;
16 | import static org.apache.commons.lang3.StringUtils.trimToEmpty;
17 |
18 | /**
19 | * Can change build status in case of errors
20 | *
21 | * @author lanwen (Merkushev Kirill)
22 | * @since 1.19.0
23 | */
24 | public class ChangingBuildStatusErrorHandler extends StatusErrorHandler {
25 |
26 | private String result;
27 |
28 | @DataBoundConstructor
29 | public ChangingBuildStatusErrorHandler(String result) {
30 | this.result = result;
31 | }
32 |
33 | public String getResult() {
34 | return result;
35 | }
36 |
37 | /**
38 | * Logs error to build console and changes build result
39 | *
40 | * @return true as of it terminating handler
41 | */
42 | @Override
43 | public boolean handle(Exception e, @NonNull Run, ?> run, @NonNull TaskListener listener) {
44 | Result toSet = Result.fromString(trimToEmpty(result));
45 |
46 | listener.error("[GitHub Commit Status Setter] - %s, setting build result to %s", e.getMessage(), toSet);
47 |
48 | run.setResult(toSet);
49 | return true;
50 | }
51 |
52 | @Extension
53 | public static class ChangingBuildStatusErrorHandlerDescriptor extends Descriptor {
54 |
55 | private static final Result[] SUPPORTED_RESULTS = {FAILURE, UNSTABLE};
56 |
57 | @Override
58 | public String getDisplayName() {
59 | return "Change build status";
60 | }
61 |
62 | @SuppressWarnings("unused")
63 | public ListBoxModel doFillResultItems() {
64 | ListBoxModel items = new ListBoxModel();
65 | for (Result supported : SUPPORTED_RESULTS) {
66 | items.add(supported.toString());
67 | }
68 | return items;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/err/ShallowAnyErrorHandler.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.err;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Descriptor;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.jenkinsci.plugins.github.extension.status.StatusErrorHandler;
8 | import org.kohsuke.stapler.DataBoundConstructor;
9 |
10 | import edu.umd.cs.findbugs.annotations.NonNull;
11 |
12 | /**
13 | * Just logs message to the build console and do nothing after it
14 | *
15 | * @author lanwen (Merkushev Kirill)
16 | * @since 1.19.0
17 | */
18 | public class ShallowAnyErrorHandler extends StatusErrorHandler {
19 |
20 | @DataBoundConstructor
21 | public ShallowAnyErrorHandler() {
22 | }
23 |
24 | /**
25 | * @return true as of its terminating handler
26 | */
27 | @Override
28 | public boolean handle(Exception e, @NonNull Run, ?> run, @NonNull TaskListener listener) {
29 | listener.error("[GitHub Commit Status Setter] Failed to update commit state on GitHub. "
30 | + "Ignoring exception [%s]", e.getMessage());
31 | return true;
32 | }
33 |
34 | @Extension
35 | public static class ShallowAnyErrorHandlerDescriptor extends Descriptor {
36 | @Override
37 | public String getDisplayName() {
38 | return "Just ignore any errors";
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/AnyDefinedRepositorySource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import com.cloudbees.jenkins.GitHubRepositoryName;
4 | import com.cloudbees.jenkins.GitHubRepositoryNameContributor;
5 | import hudson.Extension;
6 | import hudson.model.Descriptor;
7 | import hudson.model.Run;
8 | import hudson.model.TaskListener;
9 | import org.jenkinsci.plugins.github.extension.status.GitHubReposSource;
10 | import org.jenkinsci.plugins.github.util.misc.NullSafeFunction;
11 | import org.kohsuke.github.GHRepository;
12 | import org.kohsuke.stapler.DataBoundConstructor;
13 | import org.slf4j.Logger;
14 | import org.slf4j.LoggerFactory;
15 |
16 | import edu.umd.cs.findbugs.annotations.NonNull;
17 | import java.util.Collection;
18 | import java.util.List;
19 |
20 | import static org.jenkinsci.plugins.github.util.FluentIterableWrapper.from;
21 |
22 | /**
23 | * Just uses contributors to get list of resolved repositories
24 | *
25 | * @author lanwen (Merkushev Kirill)
26 | * @since 1.19.0
27 | */
28 | public class AnyDefinedRepositorySource extends GitHubReposSource {
29 |
30 | private static final Logger LOG = LoggerFactory.getLogger(AnyDefinedRepositorySource.class);
31 |
32 | @DataBoundConstructor
33 | public AnyDefinedRepositorySource() {
34 | }
35 |
36 | /**
37 | * @return all repositories which can be found by repo-contributors
38 | */
39 | @Override
40 | public List repos(@NonNull Run, ?> run, @NonNull TaskListener listener) {
41 | final Collection names = GitHubRepositoryNameContributor
42 | .parseAssociatedNames(run.getParent());
43 |
44 | LOG.trace("repositories source=repo-name-contributor value={}", names);
45 |
46 | return from(names).transformAndConcat(new NullSafeFunction>() {
47 | @Override
48 | protected Iterable applyNullSafe(@NonNull GitHubRepositoryName name) {
49 | return name.resolve();
50 | }
51 | }).toList();
52 | }
53 |
54 | @Extension
55 | public static class AnyDefinedRepoSourceDescriptor extends Descriptor {
56 | @Override
57 | public String getDisplayName() {
58 | return "Any defined in job repository";
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/BuildDataRevisionShaSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Descriptor;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.eclipse.jgit.lib.ObjectId;
8 | import org.jenkinsci.plugins.github.extension.status.GitHubCommitShaSource;
9 | import org.jenkinsci.plugins.github.util.BuildDataHelper;
10 | import org.kohsuke.stapler.DataBoundConstructor;
11 |
12 | import edu.umd.cs.findbugs.annotations.NonNull;
13 | import java.io.IOException;
14 |
15 | /**
16 | * Gets sha from build data
17 | *
18 | * @author lanwen (Merkushev Kirill)
19 | * @since 1.19.0
20 | */
21 | public class BuildDataRevisionShaSource extends GitHubCommitShaSource {
22 |
23 | @DataBoundConstructor
24 | public BuildDataRevisionShaSource() {
25 | }
26 |
27 | /**
28 | * @return sha from git's scm build data action
29 | */
30 | @Override
31 | public String get(@NonNull Run, ?> run, @NonNull TaskListener listener) throws IOException {
32 | return ObjectId.toString(BuildDataHelper.getCommitSHA1(run));
33 | }
34 |
35 | @Extension
36 | public static class BuildDataRevisionShaSourceDescriptor extends Descriptor {
37 | @Override
38 | public String getDisplayName() {
39 | return "Latest build revision";
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/BuildRefBackrefSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Descriptor;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.jenkinsci.plugins.displayurlapi.DisplayURLProvider;
8 | import org.jenkinsci.plugins.github.extension.status.GitHubStatusBackrefSource;
9 | import org.kohsuke.stapler.DataBoundConstructor;
10 |
11 | /**
12 | * Gets backref from Run URL.
13 | *
14 | * @author pupssman (Kalinin Ivan)
15 | * @since 1.22.1
16 | */
17 | public class BuildRefBackrefSource extends GitHubStatusBackrefSource {
18 |
19 | @DataBoundConstructor
20 | public BuildRefBackrefSource() {
21 | }
22 |
23 | /**
24 | * Returns absolute URL of the Run
25 | */
26 | @SuppressWarnings("deprecation")
27 | @Override
28 | public String get(Run, ?> run, TaskListener listener) {
29 | return DisplayURLProvider.get().getRunURL(run);
30 | }
31 |
32 | @Extension
33 | public static class BuildRefBackrefSourceDescriptor extends Descriptor {
34 | @Override
35 | public String getDisplayName() {
36 | return "Backref to the build";
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/ConditionalStatusResultSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Descriptor;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.apache.commons.lang3.EnumUtils;
8 | import org.jenkinsci.plugins.github.common.ExpandableMessage;
9 | import org.jenkinsci.plugins.github.extension.status.GitHubStatusResultSource;
10 | import org.jenkinsci.plugins.github.extension.status.misc.ConditionalResult;
11 | import org.kohsuke.github.GHCommitState;
12 | import org.kohsuke.stapler.DataBoundConstructor;
13 |
14 | import edu.umd.cs.findbugs.annotations.NonNull;
15 | import java.io.IOException;
16 | import java.util.Collections;
17 | import java.util.List;
18 |
19 | import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
20 | import static org.kohsuke.github.GHCommitState.ERROR;
21 | import static org.kohsuke.github.GHCommitState.PENDING;
22 |
23 | /**
24 | * Allows to define message and state for commit for different run results
25 | *
26 | * @author lanwen (Merkushev Kirill)
27 | */
28 | public class ConditionalStatusResultSource extends GitHubStatusResultSource {
29 |
30 | private List results;
31 |
32 | @DataBoundConstructor
33 | public ConditionalStatusResultSource(List results) {
34 | this.results = results;
35 | }
36 |
37 | @NonNull
38 | public List getResults() {
39 | return defaultIfNull(results, Collections.emptyList());
40 | }
41 |
42 | /**
43 | * First matching result win. Or will be used pending state.
44 | * Messages are expanded with token macro and env variables
45 | *
46 | * @return first matched result or pending state with warn msg
47 | */
48 | @Override
49 | public StatusResult get(@NonNull Run, ?> run, @NonNull TaskListener listener)
50 | throws IOException, InterruptedException {
51 |
52 | for (ConditionalResult conditionalResult : getResults()) {
53 | if (conditionalResult.matches(run)) {
54 | return new StatusResult(
55 | defaultIfNull(EnumUtils.getEnum(GHCommitState.class, conditionalResult.getState()), ERROR),
56 | new ExpandableMessage(conditionalResult.getMessage()).expandAll(run, listener)
57 | );
58 | }
59 | }
60 |
61 | return new StatusResult(
62 | PENDING,
63 | new ExpandableMessage("Can't define which status to set").expandAll(run, listener)
64 | );
65 | }
66 |
67 | @Extension
68 | public static class ConditionalStatusResultSourceDescriptor extends Descriptor {
69 | @Override
70 | public String getDisplayName() {
71 | return "Based on build result manually defined";
72 | }
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/DefaultCommitContextSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Descriptor;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.jenkinsci.plugins.github.extension.status.GitHubStatusContextSource;
8 | import org.kohsuke.stapler.DataBoundConstructor;
9 |
10 | import edu.umd.cs.findbugs.annotations.NonNull;
11 |
12 | import static com.coravy.hudson.plugins.github.GithubProjectProperty.displayNameFor;
13 |
14 | /**
15 | * Uses job name or defined in prop context name
16 | *
17 | * @author lanwen (Merkushev Kirill)
18 | * @since 1.19.0
19 | */
20 | public class DefaultCommitContextSource extends GitHubStatusContextSource {
21 |
22 | @DataBoundConstructor
23 | public DefaultCommitContextSource() {
24 | }
25 |
26 | /**
27 | * @return context name
28 | * @see com.coravy.hudson.plugins.github.GithubProjectProperty#displayNameFor(hudson.model.Job)
29 | */
30 | @Override
31 | public String context(@NonNull Run, ?> run, @NonNull TaskListener listener) {
32 | return displayNameFor(run.getParent());
33 | }
34 |
35 | @Extension
36 | public static class DefaultContextSourceDescriptor extends Descriptor {
37 | @Override
38 | public String getDisplayName() {
39 | return "From GitHub property with fallback to job name";
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/DefaultStatusResultSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import com.cloudbees.jenkins.Messages;
4 | import hudson.Extension;
5 | import hudson.Util;
6 | import hudson.model.Descriptor;
7 | import hudson.model.Run;
8 | import hudson.model.TaskListener;
9 | import org.jenkinsci.plugins.github.extension.status.GitHubStatusResultSource;
10 | import org.kohsuke.github.GHCommitState;
11 | import org.kohsuke.stapler.DataBoundConstructor;
12 |
13 | import edu.umd.cs.findbugs.annotations.NonNull;
14 | import java.io.IOException;
15 |
16 | import static hudson.model.Result.FAILURE;
17 | import static hudson.model.Result.SUCCESS;
18 | import static hudson.model.Result.UNSTABLE;
19 | import static java.util.Arrays.asList;
20 | import static org.jenkinsci.plugins.github.status.sources.misc.AnyBuildResult.onAnyResult;
21 | import static org.jenkinsci.plugins.github.status.sources.misc.BetterThanOrEqualBuildResult.betterThanOrEqualTo;
22 |
23 | /**
24 | * Default way to report about build results.
25 | * Reports about time and build status
26 | *
27 | * @author lanwen (Merkushev Kirill)
28 | * @since 1.19.0
29 | */
30 | public class DefaultStatusResultSource extends GitHubStatusResultSource {
31 |
32 | @DataBoundConstructor
33 | public DefaultStatusResultSource() {
34 | }
35 |
36 | @Override
37 | public StatusResult get(@NonNull Run, ?> run, @NonNull TaskListener listener) throws IOException,
38 | InterruptedException {
39 |
40 | // We do not use `build.getDurationString()` because it appends 'and counting' (build is still running)
41 | String duration = Util.getTimeSpanString(System.currentTimeMillis() - run.getTimeInMillis());
42 |
43 | return new ConditionalStatusResultSource(asList(
44 | betterThanOrEqualTo(SUCCESS,
45 | GHCommitState.SUCCESS, Messages.CommitNotifier_Success(run.getDisplayName(), duration)),
46 |
47 | betterThanOrEqualTo(UNSTABLE,
48 | GHCommitState.FAILURE, Messages.CommitNotifier_Unstable(run.getDisplayName(), duration)),
49 |
50 | betterThanOrEqualTo(FAILURE,
51 | GHCommitState.ERROR, Messages.CommitNotifier_Failed(run.getDisplayName(), duration)),
52 |
53 | onAnyResult(GHCommitState.PENDING, Messages.CommitNotifier_Pending(run.getDisplayName()))
54 | )).get(run, listener);
55 | }
56 |
57 | @Extension
58 | public static class DefaultResultSourceDescriptor extends Descriptor {
59 | @Override
60 | public String getDisplayName() {
61 | return "One of default messages and statuses";
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/ManuallyEnteredBackrefSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import org.jenkinsci.plugins.github.common.ExpandableMessage;
4 | import org.jenkinsci.plugins.github.extension.status.GitHubStatusBackrefSource;
5 | import org.kohsuke.stapler.DataBoundConstructor;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | import hudson.Extension;
10 | import hudson.model.Descriptor;
11 | import hudson.model.Run;
12 | import hudson.model.TaskListener;
13 |
14 | /**
15 | * Allows to manually enter backref, with env/token expansion.
16 | *
17 | * @author pupssman (Kalinin Ivan)
18 | * @since 1.21.2
19 | *
20 | */
21 | public class ManuallyEnteredBackrefSource extends GitHubStatusBackrefSource {
22 | private static final Logger LOG = LoggerFactory.getLogger(ManuallyEnteredBackrefSource.class);
23 |
24 | private String backref;
25 |
26 | @DataBoundConstructor
27 | public ManuallyEnteredBackrefSource(String backref) {
28 | this.backref = backref;
29 | }
30 |
31 | public String getBackref() {
32 | return backref;
33 | }
34 |
35 | /**
36 | * Just returns what user entered. Expands env vars and token macro
37 | */
38 | @SuppressWarnings("deprecation")
39 | @Override
40 | public String get(Run, ?> run, TaskListener listener) {
41 | try {
42 | return new ExpandableMessage(backref).expandAll(run, listener);
43 | } catch (Exception e) {
44 | LOG.debug("Can't expand backref, returning as is", e);
45 | return backref;
46 | }
47 | }
48 |
49 | @Extension
50 | public static class ManuallyEnteredBackrefSourceDescriptor extends Descriptor {
51 | @Override
52 | public String getDisplayName() {
53 | return "Manually entered backref";
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/ManuallyEnteredCommitContextSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Descriptor;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.jenkinsci.plugins.github.common.ExpandableMessage;
8 | import org.jenkinsci.plugins.github.extension.status.GitHubStatusContextSource;
9 | import org.kohsuke.stapler.DataBoundConstructor;
10 | import org.slf4j.Logger;
11 | import org.slf4j.LoggerFactory;
12 |
13 | import edu.umd.cs.findbugs.annotations.NonNull;
14 |
15 | /**
16 | * Allows to manually enter context
17 | *
18 | * @author lanwen (Merkushev Kirill)
19 | * @since 1.19.0
20 | */
21 | public class ManuallyEnteredCommitContextSource extends GitHubStatusContextSource {
22 | private static final Logger LOG = LoggerFactory.getLogger(ManuallyEnteredCommitContextSource.class);
23 |
24 | private String context;
25 |
26 | @DataBoundConstructor
27 | public ManuallyEnteredCommitContextSource(String context) {
28 | this.context = context;
29 | }
30 |
31 | public String getContext() {
32 | return context;
33 | }
34 |
35 | /**
36 | * Just returns what user entered. Expands env vars and token macro
37 | */
38 | @Override
39 | public String context(@NonNull Run, ?> run, @NonNull TaskListener listener) {
40 | try {
41 | return new ExpandableMessage(context).expandAll(run, listener);
42 | } catch (Exception e) {
43 | LOG.debug("Can't expand context, returning as is", e);
44 | return context;
45 | }
46 | }
47 |
48 | @Extension
49 | public static class ManuallyEnteredCommitContextSourceDescriptor extends Descriptor {
50 | @Override
51 | public String getDisplayName() {
52 | return "Manually entered context name";
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/ManuallyEnteredRepositorySource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import com.cloudbees.jenkins.GitHubRepositoryName;
4 | import com.google.common.annotations.VisibleForTesting;
5 | import hudson.Extension;
6 | import hudson.model.Descriptor;
7 | import hudson.model.Run;
8 | import hudson.model.TaskListener;
9 | import org.jenkinsci.plugins.github.extension.status.GitHubReposSource;
10 | import org.jenkinsci.plugins.github.util.misc.NullSafeFunction;
11 | import org.kohsuke.github.GHRepository;
12 | import org.kohsuke.stapler.DataBoundConstructor;
13 |
14 | import edu.umd.cs.findbugs.annotations.NonNull;
15 | import java.util.Collections;
16 | import java.util.List;
17 |
18 | import static org.jenkinsci.plugins.github.util.FluentIterableWrapper.from;
19 |
20 | public class ManuallyEnteredRepositorySource extends GitHubReposSource {
21 | private String url;
22 |
23 | @DataBoundConstructor
24 | public ManuallyEnteredRepositorySource(String url) {
25 | this.url = url;
26 | }
27 |
28 | public String getUrl() {
29 | return url;
30 | }
31 |
32 | @VisibleForTesting
33 | GitHubRepositoryName createName(String url) {
34 | return GitHubRepositoryName.create(url);
35 | }
36 |
37 | @Override
38 | public List repos(@NonNull Run, ?> run, @NonNull final TaskListener listener) {
39 | List urls = Collections.singletonList(url);
40 | return from(urls).transformAndConcat(new NullSafeFunction>() {
41 | @Override
42 | protected Iterable applyNullSafe(@NonNull String url) {
43 | GitHubRepositoryName name = createName(url);
44 | if (name != null) {
45 | return name.resolve();
46 | } else {
47 | listener.getLogger().printf("Unable to match %s with a GitHub repository.%n", url);
48 | return Collections.emptyList();
49 | }
50 | }
51 | }).toList();
52 | }
53 |
54 | @Extension
55 | public static class ManuallyEnteredRepositorySourceDescriptor extends Descriptor {
56 | @Override
57 | public String getDisplayName() {
58 | return "Manually entered repository";
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/ManuallyEnteredShaSource.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Descriptor;
5 | import hudson.model.Run;
6 | import hudson.model.TaskListener;
7 | import org.jenkinsci.plugins.github.common.ExpandableMessage;
8 | import org.jenkinsci.plugins.github.extension.status.GitHubCommitShaSource;
9 | import org.kohsuke.stapler.DataBoundConstructor;
10 |
11 | import edu.umd.cs.findbugs.annotations.NonNull;
12 | import java.io.IOException;
13 |
14 | /**
15 | * Allows to enter sha manually
16 | *
17 | * @author lanwen (Merkushev Kirill)
18 | * @since 1.19.0
19 | */
20 | public class ManuallyEnteredShaSource extends GitHubCommitShaSource {
21 |
22 | private String sha;
23 |
24 | @DataBoundConstructor
25 | public ManuallyEnteredShaSource(String sha) {
26 | this.sha = sha;
27 | }
28 |
29 | public String getSha() {
30 | return sha;
31 | }
32 |
33 | /**
34 | * Expands env vars and token macro in entered sha
35 | */
36 | @Override
37 | public String get(@NonNull Run, ?> run, @NonNull TaskListener listener) throws IOException, InterruptedException {
38 | return new ExpandableMessage(sha).expandAll(run, listener);
39 | }
40 |
41 | @Extension
42 | public static class ManuallyEnteredShaSourceDescriptor extends Descriptor {
43 | @Override
44 | public String getDisplayName() {
45 | return "Manually entered SHA";
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/status/sources/misc/AnyBuildResult.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources.misc;
2 |
3 | import hudson.Extension;
4 | import hudson.model.Run;
5 | import org.jenkinsci.plugins.github.extension.status.misc.ConditionalResult;
6 | import org.kohsuke.github.GHCommitState;
7 | import org.kohsuke.stapler.DataBoundConstructor;
8 |
9 | import edu.umd.cs.findbugs.annotations.NonNull;
10 |
11 | /**
12 | * Allows to set state in any case
13 | *
14 | * @author lanwen (Merkushev Kirill)
15 | * @since 1.19.0
16 | */
17 | public class AnyBuildResult extends ConditionalResult {
18 |
19 | @DataBoundConstructor
20 | public AnyBuildResult() {
21 | }
22 |
23 | /**
24 | * @return true in any case
25 | */
26 | @Override
27 | public boolean matches(@NonNull Run, ?> run) {
28 | return true;
29 | }
30 |
31 | /**
32 | * @param state state to set
33 | * @param msg message to set. Can contain env vars
34 | *
35 | * @return new instance of this conditional result
36 | */
37 | public static AnyBuildResult onAnyResult(GHCommitState state, String msg) {
38 | AnyBuildResult cond = new AnyBuildResult();
39 | cond.setState(state.name());
40 | cond.setMessage(msg);
41 | return cond;
42 | }
43 |
44 | @Extension
45 | public static class AnyBuildResultDescriptor extends ConditionalResultDescriptor {
46 | @Override
47 | public String getDisplayName() {
48 | return "result ANY";
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/util/XSSApi.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.util;
2 |
3 | import org.kohsuke.accmod.Restricted;
4 | import org.kohsuke.accmod.restrictions.NoExternalUse;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import java.net.MalformedURLException;
9 | import java.net.URL;
10 |
11 | /**
12 | * @author lanwen (Merkushev Kirill)
13 | */
14 | @Restricted(NoExternalUse.class)
15 | public final class XSSApi {
16 | private static final Logger LOG = LoggerFactory.getLogger(XSSApi.class);
17 |
18 | private XSSApi() {
19 | }
20 |
21 | /**
22 | * Method to filter invalid url for XSS. This url can be inserted to href safely
23 | *
24 | * @param urlString unsafe url
25 | *
26 | * @return safe url
27 | */
28 | public static String asValidHref(String urlString) {
29 | try {
30 | return new URL(urlString).toExternalForm();
31 | } catch (MalformedURLException e) {
32 | LOG.debug("Malformed url - {}, empty string will be returned", urlString);
33 | return "";
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/util/misc/NullSafeFunction.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.util.misc;
2 |
3 | import com.google.common.base.Function;
4 |
5 | import edu.umd.cs.findbugs.annotations.NonNull;
6 |
7 | import static com.google.common.base.Preconditions.checkNotNull;
8 |
9 | /**
10 | * This abstract class calls {@link #applyNullSafe(Object)} only after success validation of inner object for null
11 | *
12 | * @author lanwen (Merkushev Kirill)
13 | */
14 | public abstract class NullSafeFunction implements Function {
15 |
16 | @Override
17 | public T apply(F input) {
18 | return applyNullSafe(checkNotNull(input, "This function does not allow using null as argument"));
19 | }
20 |
21 | /**
22 | * This method will be called inside of {@link #apply(Object)}
23 | */
24 | protected abstract T applyNullSafe(@NonNull F input);
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/util/misc/NullSafePredicate.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.util.misc;
2 |
3 | import com.google.common.base.Predicate;
4 |
5 | import edu.umd.cs.findbugs.annotations.NonNull;
6 |
7 | import static com.google.common.base.Preconditions.checkNotNull;
8 |
9 | /**
10 | * This abstract class calls {@link #applyNullSafe(Object)} only after success validation of inner object for null
11 | *
12 | * @author lanwen (Merkushev Kirill)
13 | */
14 |
15 | public abstract class NullSafePredicate implements Predicate {
16 |
17 | @Override
18 | public boolean apply(T input) {
19 | return applyNullSafe(checkNotNull(input, "Argument for this predicate can't be null"));
20 | }
21 |
22 | /**
23 | * This method will be called inside of {@link #apply(Object)}
24 | */
25 | protected abstract boolean applyNullSafe(@NonNull T input);
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/webhook/GHEventHeader.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.webhook;
2 |
3 | import org.kohsuke.github.GHEvent;
4 | import org.kohsuke.stapler.AnnotationHandler;
5 | import org.kohsuke.stapler.InjectedParameter;
6 | import org.kohsuke.stapler.StaplerRequest2;
7 | import org.slf4j.Logger;
8 |
9 | import jakarta.servlet.ServletException;
10 | import java.lang.annotation.Documented;
11 | import java.lang.annotation.Retention;
12 | import java.lang.annotation.Target;
13 |
14 | import static java.lang.annotation.ElementType.PARAMETER;
15 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
16 | import static org.apache.commons.lang3.StringUtils.upperCase;
17 | import static org.apache.commons.lang3.Validate.isTrue;
18 | import static org.slf4j.LoggerFactory.getLogger;
19 |
20 | /**
21 | * InjectedParameter annotation to use on WebMethod parameters.
22 | * Handles GitHub's X-GitHub-Event header.
23 | *
24 | * @author lanwen (Merkushev Kirill)
25 | * @see Web Method
26 | */
27 | @Retention(RUNTIME)
28 | @Target(PARAMETER)
29 | @Documented
30 | @InjectedParameter(GHEventHeader.PayloadHandler.class)
31 | public @interface GHEventHeader {
32 | class PayloadHandler extends AnnotationHandler {
33 | /**
34 | * @see Developer manual
35 | */
36 | public static final String EVENT_HEADER = "X-GitHub-Event";
37 | private static final Logger LOGGER = getLogger(PayloadHandler.class);
38 |
39 | /**
40 | * @param type should be combined with type of {@link GHEvent}
41 | *
42 | * @return parsed {@link GHEvent} or null on empty header or unknown value
43 | */
44 | @Override
45 | public Object parse(StaplerRequest2 req, GHEventHeader a, Class type, String param) throws ServletException {
46 | isTrue(GHEvent.class.isAssignableFrom(type),
47 | "Parameter '%s' should has type %s, not %s", param,
48 | GHEvent.class.getName(),
49 | type.getName()
50 | );
51 |
52 | String header = req.getHeader(EVENT_HEADER);
53 | LOGGER.debug("Header {} -> {}", EVENT_HEADER, header);
54 |
55 | if (header == null) {
56 | return null;
57 | }
58 |
59 | try {
60 | return GHEvent.valueOf(upperCase(header));
61 | } catch (IllegalArgumentException e) {
62 | LOGGER.debug("Unknown event - {}", e.getMessage());
63 | return null;
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/jenkinsci/plugins/github/webhook/subscriber/PingGHEventSubscriber.java:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.webhook.subscriber;
2 |
3 | import com.cloudbees.jenkins.GitHubRepositoryName;
4 | import hudson.Extension;
5 | import hudson.model.Item;
6 | import java.io.IOException;
7 | import java.io.StringReader;
8 | import java.util.Set;
9 | import jakarta.inject.Inject;
10 | import org.jenkinsci.plugins.github.admin.GitHubHookRegisterProblemMonitor;
11 | import org.jenkinsci.plugins.github.extension.GHEventsSubscriber;
12 | import org.kohsuke.github.GHEvent;
13 | import org.kohsuke.github.GHEventPayload;
14 | import org.kohsuke.github.GHOrganization;
15 | import org.kohsuke.github.GHRepository;
16 | import org.kohsuke.github.GitHub;
17 | import org.slf4j.Logger;
18 | import org.slf4j.LoggerFactory;
19 |
20 | import static com.google.common.collect.Sets.immutableEnumSet;
21 | import static org.kohsuke.github.GHEvent.PING;
22 |
23 | /**
24 | * Get ping events to log them
25 | *
26 | * @author lanwen (Merkushev Kirill)
27 | * @since 1.13.0
28 | */
29 | @Extension
30 | @SuppressWarnings("unused")
31 | public class PingGHEventSubscriber extends GHEventsSubscriber {
32 | private static final Logger LOGGER = LoggerFactory.getLogger(PingGHEventSubscriber.class);
33 |
34 | @Inject
35 | private transient GitHubHookRegisterProblemMonitor monitor;
36 |
37 | /**
38 | * This subscriber is not applicable to any item
39 | *
40 | * @param project ignored
41 | * @return always false
42 | */
43 | @Override
44 | protected boolean isApplicable(Item project) {
45 | return false;
46 | }
47 |
48 | /**
49 | * @return set with only ping event
50 | */
51 | @Override
52 | protected Set events() {
53 | return immutableEnumSet(PING);
54 | }
55 |
56 | /**
57 | * Logs repo on ping event
58 | *
59 | * @param event only PING event
60 | * @param payload payload of gh-event. Never blank
61 | */
62 | @Override
63 | protected void onEvent(GHEvent event, String payload) {
64 | GHEventPayload.Ping ping;
65 | try {
66 | ping = GitHub.offline().parseEventPayload(new StringReader(payload), GHEventPayload.Ping.class);
67 | } catch (IOException e) {
68 | LOGGER.warn("Received malformed PingEvent: " + payload, e);
69 | return;
70 | }
71 | GHRepository repository = ping.getRepository();
72 | if (repository != null) {
73 | LOGGER.info("{} webhook received from repo <{}>!", event, repository.getHtmlUrl());
74 | monitor.resolveProblem(GitHubRepositoryName.create(repository.getHtmlUrl().toExternalForm()));
75 | } else {
76 | GHOrganization organization = ping.getOrganization();
77 | if (organization != null) {
78 | LOGGER.info("{} webhook received from org <{}>!", event, organization.getUrl());
79 | } else {
80 | LOGGER.warn("{} webhook received with unexpected payload", event);
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/resources/com/cloudbees/jenkins/GitHubCommitNotifier/config.groovy:
--------------------------------------------------------------------------------
1 | package com.cloudbees.jenkins.GitHubCommitNotifier
2 |
3 | import com.cloudbees.jenkins.GitHubCommitNotifier
4 |
5 | def f = namespace(lib.FormTagLib);
6 |
7 | // prepare default instance
8 | if (instance == null) {
9 | instance = new GitHubCommitNotifier()
10 | }
11 |
12 | f.advanced() {
13 | f.entry(title: _('Build status message'), field: 'statusMessage') {
14 | f.property()
15 | }
16 |
17 | f.entry(title: _('Result on failure'), field: 'resultOnFailure') {
18 | f.select()
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/resources/com/cloudbees/jenkins/GitHubCommitNotifier/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | Build\ status\ message=\u6784\u5EFA\u72B6\u6001\u6D88\u606F
24 |
--------------------------------------------------------------------------------
/src/main/resources/com/cloudbees/jenkins/GitHubCommitNotifier/help.html:
--------------------------------------------------------------------------------
1 |
2 | This notifier will set GH commit status.
3 | This step is DEPRECATED and will be migrated to new step in one of the next major plugin releases.
4 | Please refer to new universal step.
5 |
30 |
31 |
32 |
33 | ${%Polling has not run yet.}
34 |
35 |
36 |
37 |
38 | ${it.writeLogTo(output)}
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/main/resources/com/cloudbees/jenkins/GitHubPushTrigger/config.groovy:
--------------------------------------------------------------------------------
1 | package com.cloudbees.jenkins.GitHubPushTrigger
2 |
3 | import com.cloudbees.jenkins.GitHubPushTrigger
4 |
5 | tr {
6 | td(colspan: 4) {
7 | def url = descriptor.getCheckMethod('hookRegistered').toCheckUrl()
8 | def input = "input[name='${GitHubPushTrigger.class.getName().replace('.', '-')}']"
9 |
10 | div(id: 'gh-hooks-warn',
11 | 'data-url': url,
12 | 'data-input': input
13 | )
14 | }
15 | }
16 |
17 | script(src:"${rootURL}${h.getResourcePath()}/plugin/github/js/warning.js")
18 |
--------------------------------------------------------------------------------
/src/main/resources/com/cloudbees/jenkins/GitHubPushTrigger/help.html:
--------------------------------------------------------------------------------
1 | When Jenkins receives a GitHub push hook, GitHub Plugin checks to see
2 | whether the hook came from a GitHub repository which matches the Git repository defined in SCM/Git section of this job.
3 | If they match and this option is enabled, GitHub Plugin triggers a one-time polling on GITScm.
4 | When GITScm polls GitHub, it finds that there is a change and initiates a build.
5 | The last sentence describes the behavior of Git plugin,
6 | thus the polling and initiating the build is not a part of GitHub plugin.
7 |
--------------------------------------------------------------------------------
/src/main/resources/com/cloudbees/jenkins/GitHubSetCommitStatusBuilder/config.groovy:
--------------------------------------------------------------------------------
1 | package com.cloudbees.jenkins.GitHubSetCommitStatusBuilder
2 |
3 | import com.cloudbees.jenkins.GitHubSetCommitStatusBuilder
4 |
5 | def f = namespace(lib.FormTagLib);
6 |
7 | // prepare default instance
8 | if (instance == null) {
9 | instance = new GitHubSetCommitStatusBuilder()
10 | }
11 |
12 | f.dropdownDescriptorSelector(title: _('Commit context: '), field: 'contextSource')
13 |
14 | f.advanced() {
15 | f.entry(title: _('Build status message'), field: 'statusMessage') {
16 | f.property()
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/resources/com/cloudbees/jenkins/Messages.properties:
--------------------------------------------------------------------------------
1 | CommitNotifier.Success=Build {0} succeeded in {1}
2 | CommitNotifier.Unstable=Build {0} found unstable in {1}
3 | CommitNotifier.Failed=Build {0} failed in {1}
4 | CommitNotifier.Pending=Build {0} in progress...
5 | GitHubCommitNotifier.SettingCommitStatus=Setting commit status on GitHub for {0}
6 | GitHubCommitNotifier.DisplayName=Set build status on GitHub commit [deprecated]
7 | GitHubSetCommitStatusBuilder.DisplayName=Set build status to "pending" on GitHub commit
8 |
--------------------------------------------------------------------------------
/src/main/resources/com/coravy/hudson/plugins/github/GithubProjectProperty/config.groovy:
--------------------------------------------------------------------------------
1 | package com.coravy.hudson.plugins.github.GithubProjectProperty
2 |
3 | import static com.coravy.hudson.plugins.github.GithubProjectProperty.DescriptorImpl.GITHUB_PROJECT_BLOCK_NAME
4 |
5 | def f = namespace(lib.FormTagLib);
6 |
7 | f.optionalBlock(name: GITHUB_PROJECT_BLOCK_NAME, title: _('github.project'), checked: instance != null) {
8 | f.entry(field: 'projectUrlStr', title: _('github.project.url')) {
9 | f.textbox()
10 | }
11 |
12 | f.advanced() {
13 | f.entry(title: _('github.build.display.name'), field: 'displayName') {
14 | f.textbox()
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/resources/com/coravy/hudson/plugins/github/GithubProjectProperty/config.properties:
--------------------------------------------------------------------------------
1 | github.project=GitHub project
2 | github.project.url=Project url
3 | github.build.display.name=Display name
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/coravy/hudson/plugins/github/GithubProjectProperty/config_de.properties:
--------------------------------------------------------------------------------
1 | github.project=GitHub-Projekt
2 | github.project.url=Project url
3 | github.build.display.name=Display name
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/coravy/hudson/plugins/github/GithubProjectProperty/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | github.project=GitHub \u9879\u76EE
2 | github.project.url=\u9879\u76EE URL
3 | github.build.display.name=\u663E\u793A\u540D\u79F0
4 |
--------------------------------------------------------------------------------
/src/main/resources/com/coravy/hudson/plugins/github/GithubProjectProperty/help-displayName.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This value will be used as context name for
4 | commit status if status builder or
5 | status publisher is defined for this project. It should be small and clear.
6 |
7 |
8 |
9 | If you leave it empty, job name will be used for builder and publisher.
10 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/Messages.properties:
--------------------------------------------------------------------------------
1 | global.config.url.is.empty=The Jenkins URL is empty. Explicitly set the Jenkins URL in the global configuration \
2 | or in the GitHub plugin configuration to manage webhooks.
3 | global.config.hook.url.is.malformed=There is a malformed GitHub webhook URL in the global configuration ({0}). \
4 | Please ensure that the Jenkins URL is valid and ends with a forward slash or use the webhook URL override.
5 | common.expandable.message.title=Expandable message
6 | hooks.problem.administrative.monitor.displayname=GitHub Hooks Problems
7 | hooks.problem.administrative.monitor.description=Some of the webhooks failed to be registered or were removed. \
8 | You can view a detailed list of them at this page. Also you can manage the list of ignored repos.
9 | github.trigger.check.method.warning.details=The webhook for repo {0}/{1} on {2} failed to be registered \
10 | or was removed. \
11 | More info can be found on the global configuration page. This message will be dismissed if Jenkins receives \
12 | a PING event from repo webhook or if you add the repo to the ignore list in the global configuration.
13 | unknown.error=Unknown error
14 | duplicate.events.administrative.monitor.displayname=GitHub Duplicate Events
15 | duplicate.events.administrative.monitor.description=Warns about duplicate events received from GitHub.
16 | duplicate.events.administrative.monitor.blurb=Duplicate events were received from GitHub, possibly due to \
17 | misconfiguration (e.g., multiple webhooks targeting the same Jenkins controller at the repository or organization \
18 | level), potentially causing redundant builds or at least wasted work. \
19 | Click here to inspect the last tracked duplicate event payload.
20 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/admin/GitHubDuplicateEventsMonitor/description.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/admin/GitHubDuplicateEventsMonitor/message.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/admin/GitHubHookRegisterProblemMonitor/index.properties:
--------------------------------------------------------------------------------
1 | page.title=GitHub Hooks Problems
2 | ignore=Ignore
3 | disignore=Unignore
4 | ignored.projects=Ignored Projects
5 | project.header=Project
6 | message.header=Message
7 | help.for.problems=This table shows any problems with registering/removing repo webhooks. \
8 | A message will be dismissed if Jenkins receives a PING event from the corresponding repo webhook, \
9 | or if you add the repo to the ignore list. These messages will not be saved to disk, \
10 | so they will all be cleared when Jenkins restarts.
11 | help.for.ignored=This table lists any ignored projects. Any problem with the repos in this list will be declined by \
12 | administrative monitor. \
13 | You can remove a repo from this list. This list will be saved on each change and reloaded when Jenkins restarts.
14 | help.for.page.and.debug.shows=This page shows problems with webhooks, and ignored projects.
15 | help.for.page.and.debug.system.pre=A detailed stacktrace for any of the problems can be found in the
16 | help.for.page.and.debug.system.log=system log
17 | help.for.page.and.debug.system.suffix=.
18 | help.for.page.and.debug.log.pre=For improved debugging in the Jenkins interface,
19 | help.for.page.and.debug.log.enable=enable these logs
20 | help.for.page.and.debug.log.suffix=:
21 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/admin/GitHubHookRegisterProblemMonitor/message.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.admin.GitHubHookRegisterProblemMonitor
2 |
3 | def f = namespace(lib.FormTagLib)
4 |
5 | div(class: 'alert alert-warning') {
6 | form(method: 'post', action: "${rootURL}/${my?.url}/act", name: my?.id) {
7 | f.submit(name: 'yes', value: _('view'))
8 | f.submit(name: 'no', value: _('dismiss'))
9 | }
10 | text(_('hook.registering.problem'))
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/admin/GitHubHookRegisterProblemMonitor/message.properties:
--------------------------------------------------------------------------------
1 | view=View
2 | dismiss=Dismiss
3 | hook.registering.problem=There were some problems while registering or removing one or more GitHub webhooks. \
4 | Would you like to view the problems?
5 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/common/ExpandableMessage/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.common.ExpandableMessage
2 |
3 | def f = namespace(lib.FormTagLib);
4 |
5 | f.entry(title: _('Content'), field: 'content') {
6 | f.expandableTextbox()
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/common/ExpandableMessage/help-content.html:
--------------------------------------------------------------------------------
1 |
2 | Message content that will be expanded using core variable expansion i.e. ${WORKSPACE}
3 | and Token Macro Plugin tokens.
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubPluginConfig/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.config.GitHubPluginConfig
2 |
3 | import com.cloudbees.jenkins.GitHubPushTrigger
4 | import lib.FormTagLib
5 |
6 | def f = namespace(FormTagLib);
7 | def g = namespace("/lib/github")
8 |
9 | f.section(title: descriptor.displayName) {
10 | f.entry(title: _("GitHub Servers"),
11 | help: descriptor.getHelpFile()) {
12 |
13 | f.repeatableHeteroProperty(
14 | field: "configs",
15 | hasHeader: "true",
16 | addCaption: _("Add GitHub Server"))
17 | }
18 |
19 | f.advanced() {
20 | f.validateButton(
21 | title: _("Re-register hooks for all jobs"),
22 | progress: _("Scanning all items..."),
23 | method: "reRegister"
24 | )
25 |
26 | if (GitHubPushTrigger.ALLOW_HOOKURL_OVERRIDE) {
27 | f.entry(title: _("Override Hook URL")) {
28 | g.blockWrapper {
29 | f.optionalBlock(title: _("Specify another hook URL for GitHub configuration"),
30 | inline: true,
31 | checked: instance.isOverrideHookUrl()) {
32 | f.entry(field: "hookUrl") {
33 | f.textbox(checkMethod: "post")
34 | }
35 | }
36 | }
37 | }
38 | }
39 |
40 | f.entry(title: _("Shared secrets")) {
41 | f.repeatableProperty(
42 | field: "hookSecretConfigs",
43 | add: _("Add shared secret")
44 | ) {
45 | f.entry(title: "") {
46 | div(align: "right") {
47 | f.repeatableDeleteButton()
48 | }
49 | }
50 | }
51 | }
52 |
53 | f.entry(title: _("Additional actions"), help: descriptor.getHelpFile('additional')) {
54 | f.hetero_list(items: [],
55 | addCaption: _("Manage additional GitHub actions"),
56 | name: "actions",
57 | oneEach: "true", hasHeader: "true", descriptors: instance.actions())
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubPluginConfig/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | GitHub\ Servers=GitHub \u670D\u52A1\u5668
24 | Add\ GitHub\ Server=\u6DFB\u52A0 GitHub \u670D\u52A1\u5668
25 |
26 | Re-register\ hooks\ for\ all\ jobs=\u7ED9\u6240\u6709\u4EFB\u52A1\u91CD\u65B0\u6CE8\u518C hook
27 | Scanning\ all\ items...=\u626B\u63CF\u6240\u6709\u7684\u9879\u76EE...
28 |
29 | Override\ Hook\ URL=\u8986\u76D6 Hook URL
30 | Specify\ another\ hook\ URL\ for\ GitHub\ configuration=\u4E3A GitHub \u6307\u5B9A\u53E6\u5916\u4E00\u4E2A Hook URL
31 |
32 | Additional\ actions=\u9644\u52A0\u52A8\u4F5C
33 | Manage\ additional\ GitHub\ actions=\u7BA1\u7406 GitHub \u9644\u52A0\u52A8\u4F5C
34 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubPluginConfig/help-additional.html:
--------------------------------------------------------------------------------
1 |
2 | Additional actions can help you with some routines. For example, you can convert your existing login + password
3 | (stored in credentials or directly) to a GitHub personal token.
4 |
5 | If your Jenkins runs inside a firewall and is not directly reachable from the internet,
6 | set up a reverse proxy, port tunneling, and so on so that GitHub can deliver a POST request
7 | to your Jenkins at ${app.rootUrl}github-webhook/.
8 | Then specify the URL that GitHub should POST to here.
9 |
8 | This plugin doesn't do anything with the GitHub API unless you add a configuration with credentials.
9 | So if you don't want to add any configuration, you can set up hooks for this Jenkins instance manually.
10 |
11 | In this mode, in addition to configuring projects with "GitHub hook trigger for GITScm polling",
12 | you need to ensure that Jenkins gets a POST to its
13 | ${app.rootUrl}github-webhook/.
14 |
15 |
16 |
If you set up credentials
17 |
18 | In this mode, Jenkins will add/remove hook URLs to GitHub based on the project configuration.
19 | Jenkins has a single post-commit hook URL for all the repositories, and this URL will be added
20 | to all the GitHub repositories Jenkins is interested in. You should provide credentials with scope
21 | admin:repo_hook for every repository which should be managed by Jenkins. It needs to read the
22 | current list of hooks, create new hooks and remove old hooks.
23 |
24 |
25 | The Hook URL is
26 |
27 | ${app.rootUrl}github-webhook/
28 |
29 | ,
30 | and it needs to be accessible from the internet. If you have a firewall and such between
31 | GitHub and Jenkins, you can set up a reverse proxy and override the hook URL that Jenkins registers
32 | to GitHub, by checking "override hook URL" in the advanced configuration and specify to which URL
33 | GitHub should POST.
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubServerConfig/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.config.GitHubServerConfig
2 |
3 | import org.jenkinsci.plugins.github.config.GitHubServerConfig
4 |
5 | def f = namespace(lib.FormTagLib);
6 | def c = namespace(lib.CredentialsTagLib)
7 |
8 | f.entry(title: _("Name"), field: "name") {
9 | f.textbox()
10 | }
11 |
12 | f.entry(title: _("API URL"), field: "apiUrl") {
13 | f.textbox(default: GitHubServerConfig.GITHUB_URL)
14 | }
15 |
16 | f.entry(title: _("Credentials"), field: "credentialsId") {
17 | c.select(context:app, includeUser:false, expressionAllowed:false)
18 | }
19 |
20 | f.block() {
21 | f.validateButton(
22 | title: _("Test connection"),
23 | progress: _("Testing..."),
24 | method: "verifyCredentials",
25 | with: "apiUrl,credentialsId"
26 | )
27 | }
28 |
29 | f.entry() {
30 | f.checkbox(title: _("Manage hooks"), field: "manageHooks")
31 | }
32 |
33 | f.advanced() {
34 | f.entry(title: _("GitHub client cache size (MB)"), field: "clientCacheSize") {
35 | f.textbox(default: GitHubServerConfig.DEFAULT_CLIENT_CACHE_SIZE_MB)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubServerConfig/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | Name=\u540D\u79F0
24 | Credentials=\u51ED\u636E
25 | Test\ connection=\u8FDE\u63A5\u6D4B\u8BD5
26 | Testing...=\u6D4B\u8BD5\u4E2D...
27 | Manage\ hooks=\u7BA1\u7406 Hook
28 | GitHub\ client\ cache\ size\ (MB)=GitHub \u5BA2\u6237\u7AEF\u7F13\u5B58(MB)
29 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubServerConfig/help-apiUrl.html:
--------------------------------------------------------------------------------
1 |
2 | API endpoint of a GitHub server.
3 |
4 | To use public github.com, leave this field
5 | to the default value of https://api.github.com.
6 |
7 | Otherwise if you use GitHub Enterprise, specify its API endpoint here
8 | (e.g., https://ghe.acme.com/api/v3/).
9 |
3 | Jenkins will use this much space, measured in megabytes,
4 | in $JENKINS_HOME to cache data retrieved from GitHub API calls.
5 | A cache will help improve the performance by avoiding unnecessary data transfer, and by doing so it also
6 | makes it less likely to hit API rate limit
7 | (by the use of conditional GET calls).
8 |
9 |
10 | In the unlikely event that cache is causing a problem, set this to 0 to disable cache altogether.
11 |
2 | You can create your own personal access token in your account GitHub settings.
3 |
4 | Token should be registered with scopes:
5 |
6 |
admin:repo_hook - for managing hooks (read, write and delete old ones)
7 |
repo - to see private repos
8 |
repo:status - to manipulate commit statuses
9 |
10 |
11 |
12 | In Jenkins, create credentials as «Secret Text», provided by
13 | Plain Credentials Plugin.
14 |
15 |
16 | WARNING! Credentials are filtered on changing custom GitHub URL.
17 |
18 |
19 |
20 | If you have an existing GitHub login and password you can convert it to a token automatically with the help of «Manage
21 | additional GitHub actions».
22 |
2 | Will this configuration be used to manage credentials for repositories where it has admin rights?
3 | If unchecked, this credentials still can be used to manipulate commit statuses, but will be ignored to manage hooks.
4 |
2 | An optional name to help with the disambiguation of API URLs. If you have multiple GitHub Enterprise servers with non-helpful
3 | names such as s21356.example.com and s21368.example.com then giving these names can
4 | help users when they need to select the correct server from a drop-down list. If you do not provide a name,
5 | then a "best guess" will be made from the hostname part of the API URL.
6 |
2 | Pair of GitHub token and server URL. If no custom URL is specified, then the default api.github.com will be used.
3 | If your Jenkins uses multiple repositories that are spread across different
4 | user accounts, you can list them all here as separate configurations.
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubTokenCredentialsCreator/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.config.GitHubTokenCredentialsCreator
2 |
3 | import org.jenkinsci.plugins.github.config.GitHubServerConfig
4 |
5 | def f = namespace(lib.FormTagLib);
6 | def c = namespace(lib.CredentialsTagLib)
7 |
8 | f.entry(title: _("GitHub API URL"), field: "apiUrl",
9 | help: app.getDescriptor(GitHubServerConfig.class)?.getHelpFile("customApiUrl")) {
10 | f.textbox(default: GitHubServerConfig.GITHUB_URL)
11 | }
12 |
13 | f.radioBlock(checked: true, name: "creds", value: "plugin", title: "From credentials") {
14 | f.entry(title: _("Credentials"), field: "credentialsId") {
15 | c.select(context: app, includeUser: true, expressionAllowed: false)
16 | }
17 |
18 | f.block() {
19 | f.validateButton(
20 | title: _("Create token credentials"),
21 | progress: _("Creating..."),
22 | method: "createTokenByCredentials",
23 | with: "apiUrl,credentialsId"
24 | )
25 | }
26 | }
27 |
28 | f.radioBlock(checked: false, name: "creds", value: "manually", title: "From login and password") {
29 |
30 | f.entry(title: _("Login"), field: "login") {
31 | f.textbox()
32 | }
33 |
34 | f.entry(title: _("Password"), field: "password") {
35 | f.password()
36 | }
37 |
38 | f.block() {
39 | f.validateButton(
40 | title: _("Create token credentials"),
41 | progress: _("Creating..."),
42 | method: "createTokenByPassword",
43 | with: "apiUrl,login,password"
44 | )
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubTokenCredentialsCreator/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | From credentials=\u4ECE\u51ED\u636E
24 | Credentials=\u51ED\u636E
25 | Create\ token\ credentials=\u521B\u5EFA token \u51ED\u636E
26 | Creating...=\u521B\u5EFA\u4E2D...
27 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/GitHubTokenCredentialsCreator/help.html:
--------------------------------------------------------------------------------
1 |
2 | Helper to convert existing username-password credentials or directly login+password to a
3 | GitHub personal token.
4 |
5 | This helper doesn't store any entered data, but only registers a new token with all scopes needed to plugin.
6 | After token registration, it will be stored as «Secret text» credentials with domain requirements corresponding to
7 | given API URL. It will be available after refreshing the Global Confirmation page.
8 |
9 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/HookSecretConfig/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.config.HookSecretConfig
2 |
3 | def f = namespace(lib.FormTagLib);
4 | def c = namespace(lib.CredentialsTagLib);
5 |
6 | f.entry(title: _("Shared secret"), field: "credentialsId", help: descriptor.getHelpFile('sharedSecret')) {
7 | c.select(context: app, includeUser: false, expressionAllowed: false)
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/HookSecretConfig/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | Shared\ secret=\u5171\u4EAB Secret
24 |
25 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/HookSecretConfig/help-sharedSecret.html:
--------------------------------------------------------------------------------
1 |
2 | A shared secret token GitHub will use to sign requests in order for Jenkins to verify that the request came from GitHub.
3 | If left blank, this feature will not be used.
4 | Please use a different token from the token secret.
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/config/Messages.properties:
--------------------------------------------------------------------------------
1 | GitHubServerConfig.displayName={0} ({1})
2 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/extension/status/misc/ConditionalResult/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.extension.status.misc.ConditionalResult
2 |
3 |
4 | def f = namespace(lib.FormTagLib);
5 |
6 | f.entry(title: _('Status'), field: 'state') {
7 | f.select()
8 | }
9 |
10 | f.entry(title: _('Message'), field: 'message') {
11 | f.textbox()
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/extension/status/misc/ConditionalResult/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | Status=\u72B6\u6001
24 | Message=\u6D88\u606F
25 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/GitHubCommitStatusSetter/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.GitHubCommitStatusSetter
2 |
3 | import org.apache.commons.collections.CollectionUtils
4 | import org.jenkinsci.plugins.github.extension.status.StatusErrorHandler
5 |
6 |
7 | def f = namespace(lib.FormTagLib);
8 |
9 | f.section(title: _('Where:')) {
10 | f.dropdownDescriptorSelector(title: _('Commit SHA: '), field: 'commitShaSource')
11 | f.dropdownDescriptorSelector(title: _('Repositories: '), field: 'reposSource')
12 | }
13 |
14 | f.section(title: _('What:')) {
15 | f.dropdownDescriptorSelector(title: _('Commit context: '), field: 'contextSource')
16 | f.dropdownDescriptorSelector(title: _('Status result: '), field: 'statusResultSource')
17 | f.dropdownDescriptorSelector(title: _('Status backref: '), field: 'statusBackrefSource')
18 | }
19 |
20 | f.advanced {
21 | f.section(title: _('Advanced:')) {
22 | f.optionalBlock(
23 | checked: CollectionUtils.isNotEmpty(instance?.errorHandlers),
24 | inline: true,
25 | name: 'errorHandling',
26 | title: 'Handle errors') {
27 | f.block {
28 | f.hetero_list(items: CollectionUtils.isEmpty(instance?.errorHandlers)
29 | ? []
30 | : instance.errorHandlers,
31 | addCaption: 'Add error handler',
32 | name: 'errorHandlers',
33 | oneEach: true, hasHeader: true, descriptors: StatusErrorHandler.all())
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/GitHubCommitStatusSetter/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | Advanced:=\u9AD8\u7EA7\uFF1A
24 | Handle\ errors=\u9519\u8BEF\u5904\u7406
25 | Add\ error\ handler=\u6DFB\u52A0\u9519\u8BEF\u5904\u7406
26 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/GitHubCommitStatusSetter/help.html:
--------------------------------------------------------------------------------
1 |
2 | Using GitHub status api sets status of the commit.
3 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/err/ChangingBuildStatusErrorHandler/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.err.ChangingBuildStatusErrorHandler
2 |
3 | def f = namespace(lib.FormTagLib);
4 |
5 | f.entry(title: _('Result on failure'), field: 'result') {
6 | f.select()
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/err/ChangingBuildStatusErrorHandler/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | Result\ on\ failure=\u5931\u8D25\u7ED3\u679C
24 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/err/ShallowAnyErrorHandler/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.err.ShallowAnyErrorHandler
2 |
3 |
4 | def f = namespace(lib.FormTagLib);
5 |
6 | f.helpLink(url: descriptor.getHelpFile())
7 | f.helpArea()
8 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/sources/AnyDefinedRepositorySource/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources.AnyDefinedRepositorySource
2 |
3 |
4 | def f = namespace(lib.FormTagLib);
5 |
6 | f.helpLink(url: descriptor.getHelpFile())
7 | f.helpArea()
8 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/sources/AnyDefinedRepositorySource/help.html:
--------------------------------------------------------------------------------
1 |
2 | Any repository provided by the programmatic contributors list.
3 |
2 | You can define in which cases you want to publish exact state and message for the commit. You can define multiple cases.
3 | First match (starting from top) wins. If no one matches, PENDING status + warn message will be used.
4 |
4 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/sources/misc/BetterThanOrEqualBuildResult/config.groovy:
--------------------------------------------------------------------------------
1 | package org.jenkinsci.plugins.github.status.sources.misc.BetterThanOrEqualBuildResult
2 |
3 |
4 | def f = namespace(lib.FormTagLib);
5 |
6 |
7 | f.entry(title: _('Build result better than or equal to'), field: 'result') {
8 | f.select()
9 | }
10 |
11 | f.entry(title: _('Status'), field: 'state') {
12 | f.select()
13 | }
14 |
15 | f.entry(title: _('Message'), field: 'message') {
16 | f.textbox()
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/sources/misc/BetterThanOrEqualBuildResult/config_zh_CN.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2018, suren
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | Status=\u72B6\u6001
24 | Message=\u6D88\u606F
25 |
--------------------------------------------------------------------------------
/src/main/resources/org/jenkinsci/plugins/github/status/sources/misc/BetterThanOrEqualBuildResult/help-message.html:
--------------------------------------------------------------------------------
1 |