Skip to content

Please give some example pipeline code in the README #54

@aharrison24

Description

@aharrison24

Describe your use-case which is not covered by existing documentation.

I recently came across this plugin and thought it would be a really useful way to launch different tasks via PR comments. As someone who is not intimately familiar with Jenkins pipeline scripting, it would have been really useful for me to see a short snippet of code showing how I would go about retrieving the comment body from the plugin. Especially since the correct way to retrieve build causes seems to have changed over the years. Not that I even knew that I needed to retrieve build causes when I started. I got there in the end with lots of confused Googling and many many failed builds.

To save other poor souls like me from hours of frustration, please could you put a quick example in the README?

I'm thinking something like this:

script {
  def triggerCause = currentBuild.getBuildCauses("com.adobe.jenkins.github_pr_comment_build.GitHubPullRequestCommentCause")

  if (triggerCause) {
    echo("Author: ${triggerCause.commentAuthor}, Message: " +
              "\"${triggerCause.commentBody}\"")
  } else {
    echo("Build was not started by a PR comment")
  }
}

It's quite possible that's wrong, because I (still) don't really know what I'm doing. But you probably get the idea!

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions