title: How do I detect my test is running on a Jenkins environment?
body: <p>I have a JUnit test using <code>Assumption</code> to skip the test if the developer's computer doesn't have the pre-requisite software for running it. Despite being "junit", it's an integration test. Something like this:</p>
  
  <pre><code>int isSoftwarePresent = new ProcessBuilder("check software presence").start().waitFor();
  Assume.assumeThat("Software not present", isSoftwarePresent, is(equalTo(0)));
  </code></pre>
  
  <p>However, at one point I realized the test had <em>stopped</em> running on the automated build on Jenkins, due to that assumption, and eventually a regression was introduced which the test was supposed to stop.</p>
  
  <p>To put in other words, the required software went missing from Jenkins slave environment, which caused the test to be skipped.</p>
  
  <p>The automated test is run by maven with the FailSafe plugin, on a Jenkins Pipeline build plan. How can I detect that my environment is Jenkins so that I can make the assumption condition more strict?</p>
  
  <p>That is, I want the condition to be something like this:</p>
  
  <pre><code>boolean isJenkinsBuild = /* true if this is being run inside a Jenkins build, false otherwise */;
  boolean isSoftwarePresent = new ProcessBuilder("check software presence").start().waitFor() == 0;
  Assume.assumeTrue("Software not present", isSoftwarePresent || isJenkinsBuild);
  </code></pre>
  
  <p>Or even,</p>
  
  <pre><code>@Test
  void testJenkinsEnvironment() {
      ...
      Assume.assumeTrue(isJenkinsBuild);
      Assert.assertTrue(isSoftwarePresent);
  }
  
  @Test
  void testFeature() {
      ...
      Assume.assumeTrue(isSoftwarePresent);
      ...
  }
  </code></pre>