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

[JENKINS-50777] Expose SCMRevisionAction and associated metadata via Stapler export #52

Merged
merged 1 commit into from
Apr 17, 2018

Conversation

jglick
Copy link
Member

@jglick jglick commented Apr 12, 2018

JENKINS-50777

Example output with jenkinsci/git-plugin#581 + jenkinsci/github-branch-source-plugin#180 on a master build:

{
  "_class" : "jenkins.scm.api.SCMRevisionAction",
  "revision" : {
    "_class" : "jenkins.plugins.git.AbstractGitSCMSource$SCMRevisionImpl",
    "deterministic" : true,
    "head" : {
      "_class" : "org.jenkinsci.plugins.github_branch_source.BranchSCMHead",
      "name" : "master",
      "origin" : {
        "_class" : "jenkins.scm.api.SCMHeadOrigin$Default"
      }
    },
    "hash" : "c9e8148ede406f8ad89610befbdf51ba4a0ef24a"
  }
}

and on a PR merge build, specifically cloudbeers/PR-demo#20:

{
  "_class" : "jenkins.scm.api.SCMRevisionAction",
  "revision" : {
    "_class" : "org.jenkinsci.plugins.github_branch_source.PullRequestSCMRevision",
    "deterministic" : true,
    "head" : {
      "_class" : "org.jenkinsci.plugins.github_branch_source.PullRequestSCMHead",
      "name" : "PR-20",
      "origin" : {
        "_class" : "jenkins.scm.api.SCMHeadOrigin$Fork",
        "name" : "vivek"
      }
    },
    "merge" : true,
    "target" : {
      "_class" : "jenkins.plugins.git.AbstractGitSCMSource$SCMRevisionImpl",
      "deterministic" : true,
      "head" : {
        "_class" : "org.jenkinsci.plugins.github_branch_source.BranchSCMHead",
        "name" : "master",
        "origin" : {
          "_class" : "jenkins.scm.api.SCMHeadOrigin$Default"
        }
      },
      "hash" : "c9e8148ede406f8ad89610befbdf51ba4a0ef24a"
    },
    "pullHash" : "5d2f682bc7a77f253e9b887536fa08f7ba41af64"
  }
}

Example of extracting important fields from a build URL:

…/job/…/…/api/json?tree=actions[revision[hash,pullHash]]

@@ -43,6 +45,7 @@
*
* @since 2.2.0
*/
@ExportedBean
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that #35 exported SCMHead.origin yet neglected to add this annotation, causing

org.kohsuke.stapler.export.NotExportableException: class jenkins.scm.api.SCMHeadOrigin$Fork doesn't have @ExportedBean

Copy link
Member

@svanoort svanoort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems okay to me...?

@stephenc stephenc merged commit bed5b69 into jenkinsci:master Apr 17, 2018
@jglick jglick deleted the export-JENKINS-50777 branch April 17, 2018 21:03
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

Successfully merging this pull request may close these issues.

5 participants