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

Cannot run inline script when shared library is loaded #472

Open
grzegorzgrzegorz opened this issue Jan 11, 2022 · 5 comments
Open

Cannot run inline script when shared library is loaded #472

grzegorzgrzegorz opened this issue Jan 11, 2022 · 5 comments

Comments

@grzegorzgrzegorz
Copy link

grzegorzgrzegorz commented Jan 11, 2022

Jenkins and plugins versions report

Environment
Paste the output here

What Operating System are you using (both controller, and any agents involved in the problem)?

Windows

Reproduction steps

Unable to run this test:

import com.lesfurets.jenkins.unit.BasePipelineTest
import org.junit.Before
import org.junit.Test

import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
import static com.lesfurets.jenkins.unit.global.lib.ProjectSource.projectSource

class TestingExamplesFromGithub extends BasePipelineTest {

    @Override
    @Before
    void setUp() throws Exception {
        super.setUp()

        def library = library().name('commons')
                .defaultVersion('<notNeeded>')
                .allowOverride(true)
                .implicit(true)
                .targetPath('<notNeeded>')
                .retriever(projectSource())
                .build()
        helper.registerSharedLibrary(library)
    }

    @Test
    void testSomeScript() throws Exception {
        def script = runInlineScript('''
            node {
                stage('Build') {
                    echo 'make'
                }
            }
        ''')


        printCallStack()
        assertJobStatusSuccess()
    }

}

Expected Results

Test is run, stack is displayed, assertion is made.

Actual Results

Test is hanging.

Anything else?

When library is not loaded, the test can be executed successfully.

@grzegorzgrzegorz
Copy link
Author

grzegorzgrzegorz commented Feb 4, 2022

What is this play with "bug" label about? Should it not be used at all? Could you explain it @nre-ableton ?

@nre-ableton
Copy link
Contributor

I removed all labels except for "dependabot", which gets added automatically by the dependabot service by GitHub and can't be avoided. The labels weren't useful and just cluttered up the backlog.

@turboBasic
Copy link

I have encountered the same problem. Test which uses runScript('...') or runInlineScript('...') fails when library is loaded

@jiridanek
Copy link

I have one suggestion. Check the groovy version you have on your classpath. It should be

implementation('org.codehaus.groovy:groovy-all:2.4.21')

That's first because this ancient version is what Jenkins actually uses, and second, when I used 3.0.12, I saw a deadlock when loading a shared library, when the test was trying to compile the groovy. Also, this is what JenkinsPipelineUnit tests with.

JenkinsPipelineUnit has self tests for inlineScript functionality, https://github.com/RecuencoJones/JenkinsPipelineUnit/blob/master/src/test/groovy/com/lesfurets/jenkins/TestInlineScript.groovy so it is unlikely this will simply completely break.

@jiridanek
Copy link

One more note, are you using Java 11 when running tests? I found that (with groovy 3.0.13) the tests run on java 11 and get stuck the way described in this issue on 17. My colleagues were perfectly happy with that version of groovy and java 11.

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

No branches or pull requests

4 participants