Code Monkey home page Code Monkey logo

Comments (8)

lppedd avatar lppedd commented on July 20, 2024

@bluesliverx I can have a look at this myself. Although the flow of IssueCommentGHEventSubscriber is a bit of a mess.
I think I'll trade off for just the thumbs up for now.

from github-pr-comment-build-plugin.

lppedd avatar lppedd commented on July 20, 2024

Parsing the event and getting the comment to react to seems to be easy enough.
Wrote some code quickly to demonstrate.

// Add another helper method to GithubHelper
public static GitHub getGitHub(@Nonnull final Job<?, ?> job) throws IOException {
    final SCMSource scmSource = SCMSource.SourceByItem.findSource(job);

    if (scmSource instanceof GitHubSCMSource) {
        final GitHubSCMSource gitHubSource = (GitHubSCMSource) scmSource;
        final StandardCredentials credentials = Connector.lookupScanCredentials(
                job,
                gitHubSource.getApiUri(),
                gitHubSource.getCredentialsId()
        );
        return Connector.connect(gitHubSource.getApiUri(), credentials);
    }

    throw new IllegalArgumentException("Job's SCM is not GitHub.");
}

private void reactScheduled(final Job<?, ?> job, final String payload) {
    try {
        final GitHub gitHub = GithubHelper.getGitHub(job);
        final IssueComment event = gitHub.parseEventPayload(new StringReader(payload), IssueComment.class);
        event.getComment().createReaction(ReactionContent.PLUS_ONE);
    } catch (final IOException e) {
        LOGGER.log(Level.WARNING, "Could not react to triggering comment", e);
    }
}

Do you think this will work?

from github-pr-comment-build-plugin.

bluesliverx avatar bluesliverx commented on July 20, 2024

I'm not sure about this, mainly due to the credentials used. Sometimes they may have write access and the ability to comment, which I believe this needs. Other times it may not have the permissions.

Personally, a thumbs up is just as significant as the job itself starting and adding a check (which is how we're setup). I realize not all jobs may add/update the check immediately though.

from github-pr-comment-build-plugin.

lppedd avatar lppedd commented on July 20, 2024

@bluesliverx just installed and tried on our Jenkins instance. Works perfectly, and we are using auth via a GitHub App.

from github-pr-comment-build-plugin.

lppedd avatar lppedd commented on July 20, 2024

Obviously you'd need to set read & write permissions to comments.

Personally, a thumbs up is just as significant as the job itself starting

Rationale is without feedback I don't know if the job has started because of my comment or because of something else.
Especially in complex environments where multiple apps are used, jobs might be triggered for different reasons.

I would at least want to know if the comment has been received and interpreted correctly.

from github-pr-comment-build-plugin.

lppedd avatar lppedd commented on July 20, 2024

I tried with the "Read-only" permission to comments. Works ok!

image

from github-pr-comment-build-plugin.

bluesliverx avatar bluesliverx commented on July 20, 2024

Ah, interesting. I still feel like this behavior should be hidden behind a checkbox or something on the behavior dialog next to the pattern that it should match. Something like "React with thumbs up on successful comment match"

from github-pr-comment-build-plugin.

lppedd avatar lppedd commented on July 20, 2024

@bluesliverx agree. Someone might not want this.
I'm not an expert in Jenkins plugins, but the plugin already has UI elements luckily.

from github-pr-comment-build-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.