Permalink
Fetching contributors…
Cannot retrieve contributors at this time
109 lines (101 sloc) 3.78 KB
---
- job-template:
name: '{project}-{topology}-provision'
description: '{description}'
defaults: cinch-topology-setup
node: master
parameters:
- choice:
name: PROVIDER
choices:
- openstack-slave
- beaker-slave
- aws_ec2-slave
builders:
- shell: |
#!/bin/bash -ex
source "${{JENKINS_HOME}}/opt/linchpin/bin/activate"
linchpin -v --creds-path {topology_path}/${{PROVIDER}}/credentials -w {topology_path}/${{PROVIDER}} up
deactivate
source "${{JENKINS_HOME}}/opt/cinch/bin/activate"
cinch {topology_path}/${{PROVIDER}}/inventories/cinch-test.inventory
deactivate
publishers:
- archive:
artifacts: '{topology_path}/${{PROVIDER}}/inventories/cinch-test.inventory'
allow-empty: 'false'
- archive:
artifacts: '{topology_path}/${{PROVIDER}}/resources/cinch-test.output'
allow-empty: 'true'
- trigger-parameterized-builds:
- project: '{project}-{topology}-runtest'
current-parameters: true
condition: 'SUCCESS'
fail-on-missing: true
- project: '{project}-{topology}-teardown'
current-parameters: true
condition: 'UNSTABLE_OR_WORSE'
fail-on-missing: true
- job-template:
name: '{project}-{topology}-runtest'
description: '{description}'
node: '{jslave_name}'
builders:
- shell: |
#!/bin/bash -ex
echo "$JOB_NAME $BUILD_DISPLAY_NAME" > test_artifact.txt
publishers:
- archive:
artifacts: 'test_artifact.txt'
allow-empty: 'false'
- trigger-parameterized-builds:
- project: '{project}-{topology}-teardown'
current-parameters: true
- job-template:
name: '{project}-{topology}-teardown'
description: '{description}'
defaults: cinch-topology-setup
node: master
builders:
- copyartifact:
project: '{project}-{topology}-provision'
filter: '{topology_path}/${{PROVIDER}}/inventories/cinch-test.inventory'
target: '{topology_path}/${{PROVIDER}}/inventories'
flatten: true
- copyartifact:
project: '{project}-{topology}-provision'
filter: '{topology_path}/${{PROVIDER}}/resources/cinch-test.output'
target: '{topology_path}/${{PROVIDER}}/resources'
flatten: true
- shell: |
#!/bin/bash -ex
source "${{JENKINS_HOME}}/opt/cinch/bin/activate"
# Try to remove the Jenkins slave from the Jenkins master, but do not fail
# the entire teardown job if Jenkins slave disconnection cannot be done.
# This is for cases where the provision step failed to attach the slave,
# but the instance should still be destroyed by linchpin.
set +e
teardown {topology_path}/${{PROVIDER}}/inventories/cinch-test.inventory
set -e
deactivate
source "${{JENKINS_HOME}}/opt/linchpin/bin/activate"
linchpin -v --creds-path {topology_path}/${{PROVIDER}}/credentials -w {topology_path}/${{PROVIDER}} destroy
deactivate
- job-group:
name: provision-runtest-teardown
jobs:
- '{project}-{topology}-provision'
- '{project}-{topology}-runtest'
- '{project}-{topology}-teardown'
- project:
name: cinch-jobs
project: cinch
topology:
- example
jobs:
- provision-runtest-teardown
jslave_name: cinch-slave
topology_path: 'cinch-example/examples/linchpin-topologies'
description: |
cinch Jenkins slave provisioning example workflow using Jenkins Job Builder
https://github.com/RedHatQE/cinch/blob/master/jjb/ci-jslave-project-sample.yaml