Skip to content

Instantly share code, notes, and snippets.

@piyush0101
Created March 15, 2016 16:46
Show Gist options
  • Save piyush0101/d1240459fd7d8adee3ec to your computer and use it in GitHub Desktop.
Save piyush0101/d1240459fd7d8adee3ec to your computer and use it in GitHub Desktop.
---
- job:
name: project-py-build
description: >
Run unit tests and build project package
This job is managed by jenkins-job-builder. Changes made through
the web interface will be lost!
node: "big-slave"
display-name: "Build Project Application"
triggers:
- pollscm: 'H/2 * * * *'
scm:
- git:
url: "git@github.piyush0101.com:eng/project-py.git"
skip-tag: True
wipe-workspace: True
branches:
- 'master'
wrappers:
- timestamps
- ansicolor:
colormap: vga
builders:
- shell: |
export DOCKER_HOST=127.0.0.1:4243
docker run \
--rm=true \
--name=$BUILD_TAG \
-u jenkins \
-v "$WORKSPACE:$WORKSPACE:rw" \
-v "$(dirname $SSH_AUTH_SOCK):/tmp/ssh_sock" \
-w $WORKSPACE \
docker-registry.piyush0101.com:5000/slave/project \
invoke build
publishers:
- archive:
artifacts: 'build/*'
- archive:
artifacts: 'tasks.py'
- trigger-parameterized-builds:
- project: project-py-deploy-to-qa
predefined-parameters: project_version=${BUILD_NUMBER}
condition: UNSTABLE_OR_BETTER
- job:
name: project-py-deploy-to-qa
description:
Deploy Project to QA environment
<br><br>
This job is managed by jenkins-job-builder. Changes made through
the web interface will be lost!
display-name: "Deploy Project to QA Environment"
node: "big-slave"
parameters:
- string:
name: "project_version"
description: "The version of the project package we want to deploy to QA"
wrappers:
- timestamps
- ansicolor:
colormap: vga
builders:
- copyartifact:
project: project-py-build
which-build: specific-build
build-number: ${project_version}
filter: 'build/*'
target: ${WORKSPACE}
- copyartifact:
project: project-py-build
which-build: specific-build
build-number: ${project_version}
filter: 'tasks.py'
target: ${WORKSPACE}
- shell: |
export DOCKER_HOST=127.0.0.1:4243
docker run \
--rm=true \
--name=$BUILD_TAG \
-e "SSH_AUTH_SOCK=/tmp/ssh_sock/$(basename $SSH_AUTH_SOCK)" \
-u jenkins \
-v "$WORKSPACE:$WORKSPACE:rw" \
-v "/home/jenkins/.ansible:/.ansible" \
-v "$(dirname $SSH_AUTH_SOCK):/tmp/ssh_sock" \
-w $WORKSPACE \
docker-registry.piyush0101.com:5000/slave/project \
invoke deploy qa
publishers:
- trigger-parameterized-builds:
- project: project-py-functional-tests-qa
predefined-parameters: project_version=${project_version}
condition: UNSTABLE_OR_BETTER
- job:
name: project-py-functional-tests-qa
description: >
Run functional tests against Project QA
<br><br>
This job is managed by jenkins-job-builder. Changes made through
the web interface will be lost!
display-name: "Project QA Functional Tests"
node: "big-slave"
parameters:
- string:
name: "project_version"
description: "The version of the project package against which to run functional tests"
wrappers:
- timestamps
- ansicolor:
colormap: vga
builders:
- copyartifact:
project: project-py-build
which-build: specific-build
build-number: ${project_version}
filter: 'build/*'
target: ${WORKSPACE}
- shell: |
export DOCKER_HOST=127.0.0.1:4243
docker run \
--rm=true \
--name=$BUILD_TAG \
-e "SSH_AUTH_SOCK=/tmp/ssh_sock/$(basename $SSH_AUTH_SOCK)" \
-e "PROJECT_HOST=http://10.23.82.222" \
-e "BUILD_ID=$BUILD_ID" \
-u jenkins \
-v "$WORKSPACE:$WORKSPACE:rw" \
-v "$(dirname $SSH_AUTH_SOCK):/tmp/ssh_sock" \
-w $WORKSPACE/build \
docker-registry.piyush0101.com:5000/slave/project \
invoke test.functional
publishers:
- trigger-parameterized-builds:
- project: project-py-deploy-to-prod
predefined-parameters: project_version=${project_version}
condition: UNSTABLE_OR_BETTER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment