nemccarthy / stash-pullrequest-builder-plugin

A Jenkins plugin for Building Stash Pull Requests
https://wiki.jenkins-ci.org/display/JENKINS/Stash+pullrequest+builder+plugin
Other
64 stars 130 forks source link

Missing variables #84

Closed sudoash closed 8 years ago

sudoash commented 8 years ago

Jenkins version: 2.3

It seems that variables aren't being made available to Jenkins anymore resulting in the following:

git -c core.askpass=true fetch --tags --progress git@git.xxx.io:xxx/xxx.git +refs/heads/:refs/remotes/origin/ git rev-parse refs/remotes/origin/${sourceBranch}^{commit} # timeout=10 git rev-parse refs/remotes/origin/origin/${sourceBranch}^{commit} # timeout=10 git rev-parse origin/${sourceBranch}^{commit} # timeout=10 ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. Unable to expand commit SHA value org.jenkinsci.plugins.tokenmacro.MacroEvaluationException: Unrecognized macro 'sourceCommitHash' in '${sourceCommitHash}' at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:207) at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:246) at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:232) at org.jenkinsci.plugins.stashNotifier.StashNotifier.lookupCommitSha1s(StashNotifier.java:287) at org.jenkinsci.plugins.stashNotifier.StashNotifier.processJenkinsEvent(StashNotifier.java:247) at org.jenkinsci.plugins.stashNotifier.StashNotifier.perform(StashNotifier.java:205) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723) at hudson.model.Build$BuildExecution.post2(Build.java:185) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668) at hudson.model.Run.execute(Run.java:1763) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410) found no commit info Finished: FAILURE

Has anyone else been receiving these issues since upgrading Jenkins?

mandrizzle commented 8 years ago

Did you update your refspec to +refs/pull-requests/*:refs/remotes/origin/pr/* in the jenkins job?

nickbroon commented 8 years ago

This is same as this issue: https://issues.jenkins-ci.org/browse/JENKINS-34762. It is a result of a security update to Jenkins. See also https://github.com/janinko/ghprb/issues/408

nickbroon commented 8 years ago

Also being tracked at https://issues.jenkins-ci.org/browse/JENKINS-34847

almorelle commented 8 years ago

:+1:

almorelle commented 8 years ago

It is written in the JIRA issue but here's the link to the security report that introduced the breaking changes: SECURITY-170

It says that Jenkins prevents now parameters that were not defined in the job to be defined in the environment. While waiting for this plugin to adjust, you can work around this by giving Jenkins some parameters. Either you restore the previous behavior or define which parameters can go through:

nickbroon commented 8 years ago

GitHub Pull request builder plugin fixed this: https://github.com/jenkinsci/ghprb-plugin/pull/344 Hopefully something similar can be done for the Stash Pull Request Builder, as I think their designs are similar.

eirikwang commented 8 years ago

Fixed this in a branch: https://github.com/eirikwang/stash-pullrequest-builder-plugin/tree/newChange More or less the same implementation as github´s implementation Not written any tests or anything, but it now works as intended again.

nemccarthy commented 8 years ago

Could you raise a PR

fuzzmz commented 8 years ago

@eirikwang, any updates on this? @nemccarthy, alternatively you can initiate the pull request yourself to bring in the changes if you're ok with the patch.

nemccarthy commented 8 years ago

Thanks guys! Sorry been on holidays in South America for the past few months. Will get to all these over the next week and get a new build out

RishabhTayal commented 8 years ago

Any update?

mrooney commented 8 years ago

I submitted a PR with @eirikwang's changes!

nemccarthy commented 8 years ago

Thanks guys. Looking at this now

RishabhTayal commented 8 years ago

So this should be available on Jenkins now?

mrooney commented 8 years ago

It will require a version bump and new release to the Jenkins plugin repository. @nemccarthy, I am happy to bump to 1.7.0 and release if you like (updating the wiki), or if you prefer to do it, just let me know :)

MazenAtaya commented 7 years ago

I'm still facing this issue. My plugin version is 1.7.0 and I'm on Jenkins 2.7. Anyone noticed the same thing?

MazenAtaya commented 7 years ago

@almorelle A silly question, how do we provide that environment variable to Jenkins?

Flet commented 7 years ago

Updating the plugin to 1.7.0 worked, however we had to do a full restart of the jenkins service from the command line (not just a restart from the UI) in order for it to take effect.

mamouneyya commented 7 years ago

I'm still facing this issue on a fresh installation of Jenkins v2.32.2 & Plugin v1.7.0 :(

P.S. Actually, the variables started to work properly until I checked both Build only if PR is mergeable & Merge PR if build is successful in advanced settings. However, un-checking them has no effect now (already tried to restart Jenkins). It's kinda unstable!

P.P.S. Mmmm, after playing with the advanced settings it looks like that Only build when asked (with test phrase) option is the one that fires this issue! This doesn't make any sense I know... 😕

Steve973 commented 7 years ago

I'm still getting this with Jenkins 2.77 and plugin 1.7.0. I have the following options selected:

Is this fixed, and am I doing something wrong?

karloskalcium commented 6 years ago

I am also seeing this on Jenkins 2.73.1 and plugin 1.7.0. For now I'm seeing a lot of warnings in the logs, but the parameters themselves are available to the job. Anyone else have any hints on how to get rid of the warnings (I'd rather not set the global flag, as I'd like it to warn me if there are params that shouldn't be there, but this was supposed to be fixed in the latest plugin...)

alishahbaz111 commented 6 years ago

Having the same issue. Is there a way to manually set these variables?

jdelnano commented 5 years ago

Also still having these problems.