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

A job that adds GHPRB fails tests #63

Closed
darkweasel77 opened this issue Nov 22, 2016 · 3 comments · Fixed by #70
Closed

A job that adds GHPRB fails tests #63

darkweasel77 opened this issue Nov 22, 2016 · 3 comments · Fixed by #70

Comments

@darkweasel77
Copy link

When adding the ghprb plugin, tests fail regarding closures.

Using the example job from ghprb-plugin page

job('upstreamJob') {
    scm {
        git {
            remote {
                github('test-owner/test-project')
                refspec('+refs/pull/*:refs/remotes/origin/pr/*')
            }
            branch('${sha1}')
        }
    }
    triggers {
        githubPullRequest {
            admin('user_1')
            admins(['user_2', 'user_3'])
            userWhitelist('you@you.com')
            userWhitelist(['me@me.com', 'they@they.com'])
            orgWhitelist('my_github_org')
            orgWhitelist(['your_github_org', 'another_org'])
            cron('H/5 * * * *')
            triggerPhrase('OK to test')
            onlyTriggerPhrase()
            useGitHubHooks()
            permitAll()
            autoCloseFailedPullRequests()
            displayBuildErrorsOnDownstreamBuilds()
            whiteListTargetBranches(['master','test', 'test2'])
            blackListTargetBranches(['master','test', 'test2'])
            allowMembersOfWhitelistedOrgsAsAdmin()
            extensions {
                commitStatus {
                    context('deploy to staging site')
                    triggeredStatus('starting deployment to staging site...')
                    startedStatus('deploying to staging site...')
                    addTestResults(true)
                    statusUrl('http://mystatussite.com/prs')
                    completedStatus('SUCCESS', 'All is well')
                    completedStatus('FAILURE', 'Something went wrong. Investigate!')
                    completedStatus('PENDING', 'still in progress...')
                    completedStatus('ERROR', 'Something went really wrong. Investigate!')
                }
                buildStatus {
                    completedStatus('SUCCESS', 'There were no errors, go have a cup of coffee...')
                    completedStatus('FAILURE', 'There were errors, for info, please see...')
                    completedStatus('ERROR', 'There was an error in the infrastructure, please contact...')
                }
            }
        }
    }
    publishers {
        mergeGithubPullRequest {
            mergeComment('merged by Jenkins')
            onlyAdminsMerge()
            disallowOwnCode()
            failOnNonMerge()
            deleteOnMerge()
        }
    }
}

job('downstreamJob') {
    wrappers {
        downstreamCommitStatus {
            context('CONTEXT NAME')
            triggeredStatus("The job has triggered")
            startedStatus("The job has started")
            statusUrl()
            completedStatus('SUCCESS', "The job has passed")
            completedStatus('FAILURE', "The job has failed")
            completedStatus('ERROR', "The job has resulted in an error")
        }
    }
}

The error I see when running gradle clean build via a jenkins verify job:

    Expected no exception to be thrown, but got 'javaposse.jobdsl.dsl.DslScriptException'
        at spock.lang.Specification.noExceptionThrown(Specification.java:118)
        at com.target.JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:45)

        Caused by:
        javaposse.jobdsl.dsl.DslScriptException: (CookbookPullRequest.groovy, line 48) No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.githubPullRequest() is applicable for argument types: (com.target.CookbookPullRequest$_build_closure1$_closure4$_closure11) values: [com.target.CookbookPullRequest$_build_closure1$_closure4$_closure11@5ec0416e]
            at javaposse.jobdsl.dsl.DslScriptLoader.runScriptEngine(DslScriptLoader.groovy:135)
            at javaposse.jobdsl.dsl.DslScriptLoader.runScriptsWithClassLoader_closure1(DslScriptLoader.groovy:78)
            at groovy.lang.Closure.call(Closure.java:414)
            at groovy.lang.Closure.call(Closure.java:430)
            at javaposse.jobdsl.dsl.DslScriptLoader.runScriptsWithClassLoader(DslScriptLoader.groovy:68)
            at javaposse.jobdsl.dsl.DslScriptLoader.runScripts(DslScriptLoader.groovy:44)
            at javaposse.jobdsl.dsl.DslScriptLoader.runScript(DslScriptLoader.groovy:58)
            at com.target.JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:41)

            Caused by:
            groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.githubPullRequest() is applicable for argument types: (com.target.CookbookPullRequest$_build_closure1$_closure4$_closure11) values: [com.target.CookbookPullRequest$_build_closure1$_closure4$_closure11@5ec0416e]
                at javaposse.jobdsl.dsl.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:19)
                at com.target.CookbookPullRequest.build_closure1$_closure4(CookbookPullRequest.groovy:48)
                at com.target.CookbookPullRequest.build_closure1$_closure4(CookbookPullRequest.groovy)
                at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16)
                at javaposse.jobdsl.dsl.Job.triggers(Job.groovy:568)
                at com.target.CookbookPullRequest.build_closure1(CookbookPullRequest.groovy:47)
                at groovy.lang.Closure.call(Closure.java:414)
                at groovy.lang.Closure.call(Closure.java:430)
                at javaposse.jobdsl.dsl.JobParent.processItem(JobParent.groovy:136)
                at javaposse.jobdsl.dsl.JobParent.freeStyleJob(JobParent.groovy:46)
                at javaposse.jobdsl.dsl.JobParent.job(JobParent.groovy:38)
                at com.target.CookbookPullRequest.build(CookbookPullRequest.groovy:27)
                at script.run(script:13)
                at javaposse.jobdsl.dsl.DslScriptLoader.runScriptEngine(DslScriptLoader.groovy:129)
                ... 7 more

When I run ./gradle clean build locally though, I see no errors. It seems to be something that only happens when run on a jenkins slave.

@LawYard
Copy link

LawYard commented Dec 2, 2016

Linked: #64

@LawYard
Copy link

LawYard commented Dec 2, 2016

I am create issue within Jenkins Jira: JENKINS-40181

daspilker added a commit to daspilker/job-dsl-gradle-example that referenced this issue Jan 11, 2017
@darkweasel77
Copy link
Author

It works! Thanks.

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 a pull request may close this issue.

2 participants