Open oz123 opened 7 years ago
@oz123 very good question, checking...
@oz123 still no answer, I tried to debug, but totally unclear where they injected and how, so have created defect for pipeline plugin https://issues.jenkins-ci.org/browse/JENKINS-46889 let see
@terma I've set GIT_URL
in my environments
block and right before calling CompareCoverageAction
I dumped my env and see the correct value for GIT_URL
. But what appears to be happening is the call to getGitUrl does not have GIT_URL
in the envVars
. I think you know that and that's the odd problem we are trying to understand why.
Could we add a workaround such that we can pass scmVars
which contains GIT_URL
and use that? If you look at how getGitUrl is implemented, if GIT_URL
is not defined in envVars
it'll try CHANGE_URL
which, in my case, has a value, so it tries to use it. It would be nice to maybe do something like below (note untested):
final String gitUrl = envVars.get(GIT_URL_PROPERTY);
if (!gitUrl && scmVars != null && scmVars.containsKey(GIT_URL_PROPERTY)) return scmVars.get(GIT_URL_PROPERTY);
I suspect, if we do that change then we could make the following calls and it would work?
step([$class: 'CompareCoverageAction', scmVars: [GIT_URL: "git@github.com:org/repo.git"]])
step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: "git@github.com:org/repo.git"]])
I should note that I just tested this and using
step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: "git@github.com:org/repo.git"]])
works today as the code is written, which may even solve @oz123's problem now.
My problem is that the key into the db for coverage numbers don't match unless the workaround I suggested above works. Or possibly using Sonar?
@ichasepucks this definitely helped! The docs should be updated ...
@ichasepucks I have to withdraw my previous comment. While you solution works for the injection itself, it still does fix the problem. The reporting still fails. see #42
@oz123 yeah, I was going to say. I'm still not able to get this to work until my proposed fix comes in. Any comment @terma on this? I can try to build this and submit a PR, but I am not a Java programmer at all. However, it would be excellent if this got fixed. I found this https://issues.jenkins-ci.org/browse/JENKINS-35230 which seems very related. For some reason people think its acceptable to have those env vars not injected. I'm not sure we're ever going to get this working right until that is working or we properly read scmVars
.
There is an issue the way the plugin retrieve the env variable, but doing
step([$class: 'MasterCoverageAction', scmVars: [GIT_URL: env.GIT_URL]])
is working in our Github Organization folder.
But it's not working for 'CompareCoverageAction' as the CHANGE_URL (with the PR path) is taking over the scmVars parameters. Wouldn't it make sense to read from scmVars first ?
@soliad yes, that's exactly what I'm proposing as well.
I propose #45 as a quick simple fix, so we just use scmVars and do not need to care about env variable propagation
@soliad I am sorry for responding late. I am quite busy with other projects, so I can't promise to make the required changed quickly.
@oz123 yes I can take a look at the doc as well
Trying to make use of the hint you gave in README, I am still getting an error:
This is my pipeline:
Can you explain how to inject the variables?