Skip to content

Instantly share code, notes, and snippets.

@vshatravenko
Last active October 13, 2017 17:47
Show Gist options
  • Save vshatravenko/3b2006096a69b64f276c59f3638c95ae to your computer and use it in GitHub Desktop.
Save vshatravenko/3b2006096a69b64f276c59f3638c95ae to your computer and use it in GitHub Desktop.
Example pipeline with BitBucket build status and multibranch support
dockerhub-username: "valshatravenko"
dockerhub-password: "**************"
dockerhub-repo: "valshatravenko/hellonode"
repo-username: "vshatravenko"
repo-password: "**************"
repo-project: "hellonode"
repo-name: "hellonode"
repo-url: "vshatravenko@bitbucket.org:schwiffty/hellonode.git"
repo-key: |-
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
k8s-deployment: "test-hellonode"
kubeconfig: |-
---
groups:
- name: production
jobs:
- build-master
- deploy-production
- name: feature
jobs:
- build-feature
- deploy-feature
- name: pull-requests
jobs:
- build-pr
- test-pr
resource_types:
- name: kubernetes
type: docker-image
source:
repository: dkkoval/concourse-kubernetes-resource
- name: bitbucket-pr
type: docker-image
source:
repository: zarplata/concourse-git-bitbucket-pr
- name: git-multibranch
type: docker-image
source:
repository: cfcommunity/git-multibranch-resource
resources:
- name: repo-master
type: git
source:
branch: master
uri: {{repo-url}}
private_key: {{repo-key}}
- name: repo
type: git-multibranch
source:
uri: {{repo-url}}
private_key: {{repo-key}}
branches: '.*'
ignore_branches: '(master)'
- name: repo-pr
type: bitbucket-pr
source:
bitbucket_type: cloud
base_url: https://bitbucket.org
username: {{repo-username}}
password: {{repo-password}}
project: {{repo-project}}
repository: {{repo-name}}
git:
uri: {{repo-url}}
private_key: {{repo-key}}
- name: build-image
type: docker-image
source:
username: {{dockerhub-username}}
password: {{dockerhub-password}}
repository: {{dockerhub-repo}}
- name: kops
type: kubernetes
source:
namespace: default
deployment: {{k8s-deployment}}
kubeconfig: {{kubeconfig}}
jobs:
- name: test-pr
plan:
- get: repo-pr
trigger: true
version: every
passed: [build-pr]
- put: repo-pr
params:
name: "unit test"
state: INPROGRESS
- aggregate:
- task: unit-test
privileged: true
config:
platform: linux
image_resource:
type: docker-image
source:
repository: {{dockerhub-repo}}
tag: test
inputs:
- name: repo-pr
run:
path: sh
args: ['-c', 'cd repo-pr && npm install mocha --silent && npm test']
on_failure:
put: repo-pr
params:
state: FAILED
name: "unit test"
url: "http://ci.kubestage.com/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME"
on_success:
put: repo-pr
params:
state: SUCCESS
name: "unit test"
url: "http://ci.kubestage.com/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME"
- task: codestyle-check
privileged: true
config:
platform: linux
image_resource:
type: docker-image
source:
repository: {{dockerhub-repo}}
tag: test
inputs:
- name: repo-pr
run:
path: sh
args: ['-c', 'echo Testing codestyle']
on_failure:
put: repo-pr
params:
state: FAILED
name: "Codestyle check"
url: "http://ci.kubestage.com/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME"
on_success:
put: repo-pr
params:
state: SUCCESS
name: "Codestyle check"
url: "http://ci.kubestage.com/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME"
- name: build-pr
plan:
- get: repo-pr
trigger: true
- task: tag
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine
run:
path: sh
args: ['-c', 'echo test > tag/name']
outputs:
- name: tag
- put: build-image
params:
build: repo-pr
tag: tag/name
- name: build-master
plan:
- get: repo-master
trigger: true
- task: tag
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine
run:
path: sh
args: ['-c', 'echo test > tag/name']
outputs:
- name: tag
- put: build-image
params:
build: repo-master
tag: tag/name
- name: deploy-production
serial: true
plan:
- get: repo-master
- task: tag
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine/git
run:
path: sh
args: ['-c', 'git describe > ../tag/name']
dir: repo-master
inputs:
- name: repo-master
outputs:
- name: tag
- put: build-image
params:
build: repo-master
tag: tag/name
- put: kops
- name: build-feature
plan:
- get: repo
trigger: true
- task: tag
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine
run:
path: sh
args: ['-c', 'echo test > tag/name']
outputs:
- name: tag
- put: build-image
params:
build: repo
tag: tag/name
- name: deploy-feature
serial: true
plan:
- get: repo
trigger: true
passed: [build-feature]
- task: tag
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine/git
run:
path: sh
args: ['-c', 'git describe --abbrev=0 > ../tag/name']
dir: repo
inputs:
- name: repo
outputs:
- name: tag
- put: build-image
params:
build: repo
tag: tag/name
- task: kops-feature
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine/git
run:
path: sh
args: ['-c', 'echo Deployed to Kubernetes cluster']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment