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

Improve test execution and reporting for Java8 template #156

Open
psoares opened this issue Jun 20, 2019 · 0 comments
Open

Improve test execution and reporting for Java8 template #156

psoares opened this issue Jun 20, 2019 · 0 comments

Comments

@psoares
Copy link

psoares commented Jun 20, 2019

The current multi-stage build Dockerfile executes a simple gradle build without ways of injecting variables to the test task. Tests that depend on environment variables will fail. A particular use case is an integration test that retrieves credentials from the outside.

Expected Behaviour

I should be able to pass system properties and gradle properties to the build command, so I can add them to build.gradle.
See https://docs.gradle.org/current/userguide/build_environment.html

Current Behaviour

Assuming the following test:

public class IntegrationTests {

    private Logger log = LoggerFactory.getLogger(IntegrationTests.class);

    @Test
    public void testTheRealDB() {
       
        assertNotNull("Missing DB_USER environment variable", System.getenv("DB_USER"));
        assertNotNull("Missing DB_PSWD environment variable", System.getenv("DB_PSWD"));

        String username = System.getenv("DB_USER");
        String password = System.getenv("DB_PSWD");
        // [...] 
    }
}

Possible Solution

Allow for extra arguments in the gradle build command.
e.g. on the Dockerfile, replace line 23:

RUN gradle build

by

ENV GRADLE_BUILD_ARGS=""
RUN gradle build $GRADLE_BUILD_ARGS

Context

Can't run a test similar to the above from a Jenkins CI build.

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
    Docker 18.09.2
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    Kubernetes
  • Operating System and version (e.g. Linux, Windows, MacOS):
    MacOS
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

1 participant