Skip to content

Instantly share code, notes, and snippets.

View jay-johnson's full-sized avatar

Jay jay-johnson

View GitHub Profile
@jay-johnson
jay-johnson / Start Django Tests
Last active July 19, 2016 13:57
Start Django Tests
// 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})"
@jay-johnson
jay-johnson / Wait for Django to Start
Last active July 25, 2016 16:52
Wait for Django to Start
// 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")
@jay-johnson
jay-johnson / Run Django Container with Jenkins Pipeline
Created July 15, 2016 06:10
Run Django Container with Jenkins Pipeline
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
@jay-johnson
jay-johnson / Run the Django container using the env-file, mounted volumes and ports
Last active July 19, 2016 13:48
Run the Django container using the env-file, mounted volumes and ports
// 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 ->
@jay-johnson
jay-johnson / Start Django Build
Last active July 19, 2016 12:55
Start Django Build
// 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}"
@jay-johnson
jay-johnson / Docker Registry Setup
Last active July 19, 2016 12:50
Docker Registry Setup
stage 'Building Django Container for Docker Hub'
docker.withRegistry("${registry_url}", "${docker_creds_id}") {
@jay-johnson
jay-johnson / Define the Repo
Created July 15, 2016 06:07
Define the Repo
stage 'Checking out GitHub Repo'
git url: 'https://github.com/jay-johnson/docker-django-nginx-slack-sphinx.git'
@jay-johnson
jay-johnson / Jenkins Pipeline - Set up Auth Credentials
Last active July 19, 2016 14:19
Jenkins Pipeline - Set up Auth Credentials
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
@jay-johnson
jay-johnson / Run CJE Docker Container
Created July 15, 2016 06:05
Run CJE Docker Container
$ 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

DEMO TITLE