{"id":15045310,"url":"https://github.com/jenkinsci/docker-fixtures","last_synced_at":"2025-10-19T21:31:14.275Z","repository":{"id":16850946,"uuid":"80128427","full_name":"jenkinsci/docker-fixtures","owner":"jenkinsci","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-06T18:43:30.000Z","size":221,"stargazers_count":6,"open_issues_count":0,"forks_count":25,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T04:25:12.256Z","etag":null,"topics":["docker","testing"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jenkinsci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-26T15:46:54.000Z","updated_at":"2025-01-06T18:43:33.000Z","dependencies_parsed_at":"2024-06-10T23:24:36.579Z","dependency_job_id":"22c0a508-c85a-4ce5-80c0-4fc5a5d9e0a4","html_url":"https://github.com/jenkinsci/docker-fixtures","commit_stats":{"total_commits":159,"total_committers":16,"mean_commits":9.9375,"dds":0.4779874213836478,"last_synced_commit":"ca7f3a569b6aa7854d8968a1e7b0bbd954d53459"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fdocker-fixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fdocker-fixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fdocker-fixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Fdocker-fixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenkinsci","download_url":"https://codeload.github.com/jenkinsci/docker-fixtures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237215757,"owners_count":19273551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","testing"],"created_at":"2024-09-24T20:51:43.078Z","updated_at":"2025-10-19T21:31:13.955Z","avatar_url":"https://github.com/jenkinsci.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nA Docker test fixture system available for use from any JUnit tests,\nespecially using `JenkinsRule` in the [Jenkins functional test harness](https://github.com/jenkinsci/jenkins-test-harness/blob/master/README.md).\n\nThe use case is for tests which need to connect to some kind of self-contained (Linux) service\nwhich cannot be easily hosted on the test machine itself.\nTypical examples would include Jenkins agents with specific software packages preloaded,\nor SCM servers which it would be hard to launch portably from any environment.\n\nAnother reason to run some things inside Docker is to simply simulate cases where code runs remotely,\nwith different filesystem paths, user accounts, etc.\n\nNote that the typical architecture is that of a single machine with a local Docker daemon.\nTests are assumed to be running on the host itself;\ni.e., this is unlike a multicontainer test system you might orchestrate with Docker Compose.\n\nProbably this library should be deprecated in favor of [testcontainers.org](https://www.testcontainers.org/).\n\n# Usage\n\n## Defining a fixture\n\nEach fixture is defined in terms of a `DockerContainer` subtype with a `@DockerFixture` annotation.\nThis type typically exposes various methods needed to interact with the running fixture.\n\nA fixture also needs to define a `Dockerfile` in the resources directory.\nIf a fixture class is `org/acme/FooContainer.java`,\nthen by default the definition must be located at `org/acme/FooContainer/Dockerfile`.\n(In the case of inner classes, dollar sign (`$`) is replaced with a slash (`/`).)\nThe same directory may contain other files `ADD`ed to or `COPY`d into the image, as usual with `docker build`.\n\n### Subclassing another fixture\n\nIf your fixture extends another one rather than `DockerContainer` directly,\nyou can inherit behaviors while adding new ones.\nIn this case the `FROM` directive of your `Dockerfile` should specify the image of the parent,\nas detailed in the Javadoc for `DockerFixture`.\n\n## Running a fixture\n\nSimply add to your (JUnit 4) test:\n\n```java\n@ClassRule\npublic static DockerClassRule\u003cMyContainer\u003e docker = new DockerClassRule\u003c\u003e(MyContainer.class);\n```\n\nIf and when you wish to start using the fixture from a test case, call the `create()` method.\nThis will launch the container and give you a handle you can use to call fixture methods.\n\nIf the test is run on a system which cannot run the `docker` command,\nthe test will be treated as skipped automatically.\n\nWhen the test case finishes, the container is stopped and cleaned up automatically.\n\n## Accessing ports\n\nWhen you specify `ports` in the annotation, you allow services in the fixture to be accessed from the test.\nAlways use the `ipBound` and `port` methods on each container to determine where to make the actual connection.\n\n## Custom networks\nIf you want your docker containers to connect to a custom network you can set the environment variable `DOCKER_FIXTURES_NETWORK` to the name of the network you want to use.\n\n## Example\n\nSee the `mercurial-plugin` sources for a complete example of defining and using a fixture, including inheritance:\n* `src/test/java/hudson/plugins/mercurial/MercurialContainer.java` declares the fixture, along with some helper nethods\n* `src/test/resources/hudson/plugins/mercurial/MercurialContainer/Dockerfile` defines the fixture’s contents\n* `src/test/java/hudson/plugins/mercurial/MercurialContainerTest.java` demonstrates its usage\n\n# Changelog\n\nSee [GitHub Releases](https://github.com/jenkinsci/docker-fixtures/releases).\n(For 1.8 and earlier, see the [old changelog](old-changelog.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkinsci%2Fdocker-fixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenkinsci%2Fdocker-fixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkinsci%2Fdocker-fixtures/lists"}