Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please give some example pipeline code in the README #54

Open
aharrison24 opened this issue Nov 2, 2022 · 0 comments
Open

Please give some example pipeline code in the README #54

aharrison24 opened this issue Nov 2, 2022 · 0 comments

Comments

@aharrison24
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant