I’m trying to add Junit to my Jenkins pipeline by using JenkinsPipelineUnit.
Before I’m starting check the pipeline flow I want to check some environment configuration.
For example: My pipeline use mvn step. I want to check: 1. maven is installed in the machine 2. maven version is x.y.z.
another: by git steps use credentials. I want to unsure the credentials defined correct in Jenkins and I can identified by this credential.
and ext’
run sh script can be a solution (‘mvn -version’). but I don’t sure this is the best way.
I’m looking for examples for similar tests, or any other help information.
Do you have any information about it?
Accepted how? As in actually installed and available?
Correct how? I’m assuming is available?
I don’t think the test framework actually has access to Jenkins data. I havnt used the framework myself but I think if acceptable is “one of those values” it should be doable. If it’s “is a system defined value” I think you’ll have trouble.
I don’t think the junit framework is supposed to test the actual agents. Something like ansible/chef/terraform would let you define the setup.
In addition, you can use the tools system to auto install on demand tools like maven - Pipeline Syntax
I think you’re trying to check that the agent configuration is correct.
There are several different configuration levels where I’ve seen failures in the past. Some of those layers have included:
Agent labels match operating system (Windows, Linux, OpenBSD, FreeBSD, macOS, etc.) - Consider using the platform labeler plugin so that the labels are maintained automatically. I use platform labeler plugin to label agents for their operating system and then use the implied labels plugin to map the automatically generated labels to more general purpose labels. That allows me to have an automatically maintained label FreeBSD that means any FreeBSD version, while platform labeler provides labels with detailed version numbers
Agent has correct tool versions installed - Use a global tool installer to install the desired tool on an agent, or if using statically installed tools, consider using label verifier plugin to confirm labels are correct on agents. I use label verifier to warn me if an agent is labeled for a specific version of command line git and a different version of command line git is detected
Dynamically allocated agent can be allocated and has correct tools - The ci.jenkins.iocheck agent availability job attempts to allocate a representative of each agent type that is relevant on that Jenkins instance. I use the “failed” rss feed for that job to alert me when that job is failing
I’m sure there are other configuration checks and sanity checks that might be considered. Those are the three that I’ve been using.