This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this pipeline is using 3 tests | |
// by setting it to more than 3 you can test the error handling and see the pipeline Stage View error message | |
MAX_TESTS = 3 | |
for (test_num = 0; test_num < MAX_TESTS; test_num++) { | |
echo "Running Test(${test_num})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wait for the django server to be ready for testing | |
// the 'waitUntil' block needs to return true to stop waiting | |
// in the future this will be handy to specify waiting for a max interval: | |
// https://issues.jenkins-ci.org/browse/JENKINS-29037 | |
waitUntil { | |
sh "docker exec -t ${container_name} netstat -apn | grep 80 | grep LISTEN | wc -l | tr -d '\n' > /tmp/wait_results" | |
wait_results = readFile '/tmp/wait_results' | |
echo "Wait Results(${wait_results})" | |
if ("${wait_results}" == "1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
stage "Testing Django container" | |
echo "-e ENV_BASE_DOMAIN=${env.ENV_BASE_DOMAIN} -e ENV_GOOGLE_ANALYTICS_CODE=${env.ENV_GOOGLE_ANALYTICS_CODE} -e ENV_DJANGO_DEBUG_MODE=${env.ENV_DJANGO_DEBUG_MODE} -e ENV_SERVER_MODE=${env.ENV_SERVER_MODE} -e ENV_DEFAULT_PORT=${env.ENV_DEFAULT_PORT} -e ENV_BASE_HOMEDIR=${env.ENV_BASE_HOMEDIR} -e ENV_BASE_REPO_DIR=${env.ENV_BASE_REPO_DIR} -e ENV_BASE_DATA_DIR=${env.ENV_BASE_DATA_DIR} -v ${env.ENV_DEFAULT_ROOT_VOLUME}:${env.ENV_DEFAULT_ROOT_VOLUME} -v ${env.ENV_DOC_SOURCE_DIR}:${env.ENV_DOC_SOURCE_DIR} -v ${env.ENV_DOC_OUTPUT_DIR}:${env.ENV_DOC_OUTPUT_DIR} -v ${env.ENV_STATIC_OUTPUT_DIR}:${env.ENV_STATIC_OUTPUT_DIR} -v ${env.ENV_MEDIA_DIR}:${env.ENV_MEDIA_DIR} -p 82:80 -p 444:443" | |
docker.image("jayjohnson/${env.CONTAINER_NAME}:${env.BUILD_TAG}").withRun("--name=${env.CONTAINER_NAME} -e ENV_BASE_DOMAIN=${env.ENV_BASE_DOMAIN} -e ENV_GOOGLE_ANALYTICS_CODE=${env.ENV_GOOGLE_ANALYTICS_CODE} -e ENV_DJANGO_DEBUG_MODE=${env.ENV_DJANGO_DEBUG_MODE} -e ENV_SERVER_MODE=${e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run the container with the env file, mounted volumes and the ports: | |
docker.image("${maintainer_name}/${container_name}:${build_tag}").withRun("--name=${container_name} --env-file ${docker_env_file} -e ENV_SERVER_MODE=DEV -v ${default_root_volume}:${default_root_volume} -v ${doc_source_dir}:${doc_source_dir} -v ${doc_output_dir}:${doc_output_dir} -v ${static_output_dir}:${static_output_dir} -v ${media_dir}:${media_dir} -p 82:80 -p 444:443") { c -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set up the container to build | |
maintainer_name = "jayjohnson" | |
container_name = "django-slack-sphinx" | |
docker_env_file = "testing.env" | |
// Read testing environment file: | |
docker_env_values = readProperties file: "./${docker_env_file}" | |
// Assign variables based off the env file | |
default_root_volume = "${docker_env_values.ENV_DEFAULT_ROOT_VOLUME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage 'Building Django Container for Docker Hub' | |
docker.withRegistry("${registry_url}", "${docker_creds_id}") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage 'Checking out GitHub Repo' | |
git url: 'https://github.com/jay-johnson/docker-django-nginx-slack-sphinx.git' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
registry_url = "https://index.docker.io/v1/" // Docker Hub | |
docker_creds_id = "jayjohnson-DockerHub" // name of the Jenkins Credentials ID | |
build_tag = "testing" // default tag to push for to the registry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker run -p 8080:8080 -p 50000:50000 -d --name cje -v /var/run/docker.sock:/var/run/docker.sock -v /usr/local/bin/docker:/usr/local/bin/docker cloudbees/jenkins-enterprise |