{"action":"closed","issue":{"url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/171","repository_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin","labels_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/171/comments","events_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/171/events","html_url":"https://github.com/jenkinsci/ghprb-plugin/issues/171","id":105345970,"number":171,"title":"Incorrect revision is picked up by matrix builds","user":{"login":"p0deje","id":665846,"avatar_url":"https://avatars.githubusercontent.com/u/665846?v=3","gravatar_id":"","url":"https://api.github.com/users/p0deje","html_url":"https://github.com/p0deje","followers_url":"https://api.github.com/users/p0deje/followers","following_url":"https://api.github.com/users/p0deje/following{/other_user}","gists_url":"https://api.github.com/users/p0deje/gists{/gist_id}","starred_url":"https://api.github.com/users/p0deje/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p0deje/subscriptions","organizations_url":"https://api.github.com/users/p0deje/orgs","repos_url":"https://api.github.com/users/p0deje/repos","events_url":"https://api.github.com/users/p0deje/events{/privacy}","received_events_url":"https://api.github.com/users/p0deje/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-08T10:08:36Z","updated_at":"2016-03-21T05:45:27Z","closed_at":"2016-03-21T05:45:27Z","body":"There is a problem which prevents configuration builds of multi-configuration (aka matrix) jobs to properly pick up the revision to be built against. There is no similar problem in usual freestyle jobs. When matrix job is configured to run at pull requests, the first time it's being run against a particular pull request, everything works fine. However, all other subsequent builds of this job against the same pull request will do the following:\r\n\r\n1. Parent build is checked to correct revision.\r\n2. Configuration builds are checked to the revision of previous parent build.\r\n\r\nI'll try to follow this bug step by step:\r\n\r\n1. When new build is started, Ghprb [adds last build BuildData to this run](https://github.com/janinko/ghprb/blob/a6d794f974fb66be7e2945be4dd62065ddcb585a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbTrigger.java#L173) to calculate changelog (`findPreviousBuildForPullId` call).\r\n2. The revision is correctly determined and checked out to by parent build.\r\n3. Configuration builds now start. Git plugin has to ensure that both parent and configuration builds are checked out to the same revision, so [it tries to determine parent revision by looking at parent's BuildData](https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java#L920-931).\r\n4. Since parent has 2 build datas (one from current build, one from last build), configuration builds check out to last build revision, not the current one.\r\n\r\nI'm not sure how this can be fixed, so I simply removed the line to add last build data (I don't really use since I configure job to always calculate changelog against pull request target branch):\r\n\r\n```diff\r\n-        return this.job.scheduleBuild2(job.getQuietPeriod(), cause, new ParametersAction(values), findPreviousBuildForPullId(pullIdPv));\r\n+        return this.job.scheduleBuild2(job.getQuietPeriod(), cause, new ParametersAction(values));\r\n```"}}