-
Notifications
You must be signed in to change notification settings - Fork 29
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
Run integration tests with specific files in workspace directory #98
Comments
Good question - there isn't an example for this right now, and this is a pretty obvious use case I've missed. I'll try and think about it and come up with an answer tomorrow. |
Would you expect it to work with the existing |
Hm, good question. I think there is definitely a trade-off here:
As I mentioned, dropping some files into the workspace while effectively turning Thanks for the quick and thoughtful response! |
I definitely think including a another repository, submodules, or separate repository, is too much overhead. I'm thinking that if there is a way to inject a "mock I haven't been a Jenkins user for a while, so I'm trying to think of how users would typically get stuff into their workspace, and I feel like A not-so-pleasant workaround for now could use the def "use files in workspace"() {
given:
WorkflowJob workflowJob = rule.createProject(WorkflowJob, 'project')
String someWorkspaceFileContents = """
some file with text
be careful about indentation
also be careful with escaping
""".stripIndent()
workflowJob.definition = new CpsFlowDefinition("""
node {
writeFile(file: 'file.txt', text: '''
$someWorkspaceFileContents
'''.stripIndent())
sh 'cat file.txt'
}
""".stripIndent(), true)
when: 'workflow executed'
QueueTaskFuture<WorkflowRun> defaultsRun = workflowJob.scheduleBuild2(0)
then: 'build output echos file contents'
WorkflowRun result = rule.assertBuildStatusSuccess(defaultsRun)
rule.assertLogContains(someWorkspaceFileContents, result)
} I definitely think there can be some improvements here, not sure about the best route and user experience for this feature, yet. |
Agreed!
I would say so, yes.
It's a bit of a hack, but it looks like it would work for us! We will try the workaround while a cleaner solution is in the works. Thank you so much for your help! |
I found https://jenkins.io/doc/developer/testing/ which has a similar suggestion to mine and and also shows an example of using the Unfortunately, it doesn't show a way to basically mock the |
I think you can mock by creating a Script instance with
and then in the before method
|
Thanks, guys. For now we are just using vanilla JenkinsPipelineUnit, but if an easier-to-maintain solution pops up here, we may consider it. |
My fault @seanfisk , I thought you were talking about integration testing using |
Hi, thank you for creating this library!
We are hoping to run an integration test with a particular set of files in our workspace directory to ensure our pipeline is running successfully. We've consulted the example repository but have only found examples that run with an empty workspace.
Is there an easy way to populate the workspace with these files before the test is run?
We have used Jenkins for a while in my organization but are just starting with shared libraries, and I found this plugin in hopes that I'll be able to use it to test our first shared library. This may be a basic question, but we're stuck on it and since your project is very active, I figured I would ask! Thank you!
The text was updated successfully, but these errors were encountered: