nishio-dens / bitbucket-pullrequest-builder-plugin

Bitbucket Pull Request Builder Plugin for Jenkins
Other
125 stars 145 forks source link

Variables not set in pipeline #215

Closed JasonDictos closed 4 years ago

JasonDictos commented 4 years ago

Jenkins Version: 2.204.1 Bitbucket Pullrequest Builder Plugin Version: 1.5.0 Git Plugin Version: 4.0.0

Job type: Pipeline with Jenkins file in source code

Problem: When configuring the SCM git hook, the Branches to build field does not pickup ${sourceBranch} env variable. Nor does the merge branch option pickup the ${targetBranch} variable.

Logs:


hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- origin +refs/heads/${sourceBranch}:refs/remotes/origin/${sourceBranch}" returned status code 128:
stdout: 
stderr: remote: Repository ${repositoryOwner}/${repositoryname} not found
fatal: repository 'https://bitbucket.org/${repositoryOwner}/${repositoryName}.git/' not found

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2372)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1985)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:80)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:563)
    at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:348)
    at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
    at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:299)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:427)
Finished: FAILURE```

Any ideas? This seems like a pretty basic setup. 
JasonDictos commented 4 years ago

I started poking around the job files, and I did see the envs in the xml file. And it does actually do the right thing if I let it trigger itself. It will not figure out the targetBranch or sourceBranch however if I run it manually (as it has no input params I suppose). I recall reading in the instructions that it should be run at least once manually to 'kick it off', but I guess I'm a little confused on that part.

Either way this does work for now.

CodeMonk commented 4 years ago

I think the issue is that a MANUAL job will never work, since it doesn't have those environment variables. Only pull-request triggered jobs work.