-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* trigger pipeline * lint * lint * Move to new orb-tools version (#62) * Update alpha.sh
- Loading branch information
Showing
4 changed files
with
137 additions
and
54 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
version: 2.1 | ||
|
||
parameters: | ||
run-integration-tests: | ||
type: boolean | ||
default: false | ||
dev-orb-version: | ||
type: string | ||
default: "dev:alpha" | ||
|
||
orbs: | ||
orb-tools: circleci/[email protected] | ||
swissknife: roopakv/swissknife@dev:alpha | ||
orb-tools: circleci/[email protected] | ||
swissknife: roopakv/swissknife@<<pipeline.parameters.dev-orb-version>> | ||
cli: circleci/[email protected] | ||
|
||
jobs: | ||
# TODO remove after https://github.com/CircleCI-Public/orb-tools-orb/pull/95/files | ||
pack: | ||
executor: cli/default | ||
working_directory: /home/circleci/orbs | ||
steps: | ||
- checkout | ||
- run: | ||
name: pack | ||
command: | | ||
circleci orb pack --skip-update-check src > orb.yml | ||
- orb-tools/validate: | ||
orb-path: orb.yml | ||
- persist_to_workspace: | ||
paths: | ||
- orb.yml | ||
root: . | ||
- store_artifacts: | ||
path: orb.yml | ||
|
||
test_run_if_modified: | ||
executor: orb-tools/ubuntu | ||
working_directory: /home/circleci/orbs | ||
|
@@ -74,40 +102,44 @@ jobs: | |
command: | | ||
circleci config pack src > LICENCE | ||
test_trigger_pipeline: | ||
executor: orb-tools/ubuntu | ||
working_directory: /home/circleci/orbs | ||
steps: | ||
- checkout | ||
- swissknife/trigger-pipeline: | ||
install-skip-trigger: true | ||
- run: | ||
command: | | ||
cat /tmp/swissknife/trigger_pipeline.sh | ||
export PARAMS='{"a": "b"}' | ||
/tmp/swissknife/trigger_pipeline.sh github roopakv orbs $CIRLE_BRANCH $PARAMS | ||
workflows: | ||
lint-pack-validate-publish-dev: | ||
unless: << pipeline.parameters.run-integration-tests >> | ||
jobs: | ||
- orb-tools/lint | ||
|
||
- orb-tools/pack: | ||
- pack: | ||
requires: [orb-tools/lint] | ||
|
||
- orb-tools/publish-dev: | ||
orb-name: roopakv/swissknife | ||
requires: [orb-tools/pack] | ||
requires: [pack] | ||
|
||
- orb-tools/trigger-integration-workflow: | ||
- orb-tools/trigger-integration-tests-workflow: | ||
name: trigger-integration-dev | ||
ssh-fingerprints: 39:1e:f6:7e:f0:aa:db:10:4e:84:30:6d:9c:dc:90:9e | ||
requires: [orb-tools/publish-dev] | ||
filters: | ||
branches: | ||
ignore: master | ||
|
||
- orb-tools/trigger-integration-workflow: | ||
name: trigger-integration-master | ||
ssh-fingerprints: 39:1e:f6:7e:f0:aa:db:10:4e:84:30:6d:9c:dc:90:9e | ||
tag: master | ||
requires: [orb-tools/publish-dev] | ||
filters: | ||
branches: | ||
only: master | ||
|
||
build: | ||
jobs: | ||
- test_run_if_modified | ||
- test_run_on_branch | ||
- test_fail_if_dirty | ||
# - test_trigger_pipeline | ||
|
||
integration_tests-prod_deploy: | ||
jobs: | ||
|
@@ -149,49 +181,20 @@ workflows: | |
branches: | ||
ignore: /.*/ | ||
tags: | ||
only: /master-m.*/ | ||
only: /.*-release.*/ | ||
|
||
# patch, minor, or major publishing | ||
- orb-tools/dev-promote-prod: | ||
name: dev-promote-patch | ||
orb-name: roopakv/swissknife | ||
cleanup-tags: true | ||
ssh-fingerprints: 39:1e:f6:7e:f0:aa:db:10:4e:84:30:6d:9c:dc:90:9e | ||
requires: | ||
- publish-approval | ||
filters: | ||
branches: | ||
ignore: /.*/ | ||
tags: | ||
only: /master-patch.*/ | ||
|
||
- orb-tools/dev-promote-prod: | ||
name: dev-promote-minor | ||
release: minor | ||
orb-name: roopakv/swissknife | ||
cleanup-tags: true | ||
ssh-fingerprints: 39:1e:f6:7e:f0:aa:db:10:4e:84:30:6d:9c:dc:90:9e | ||
requires: | ||
- publish-approval | ||
filters: | ||
branches: | ||
ignore: /.*/ | ||
tags: | ||
only: /master-minor.*/ | ||
|
||
- orb-tools/dev-promote-prod: | ||
name: dev-promote-major | ||
release: major | ||
- orb-tools/dev-promote-prod-from-git-tag: | ||
name: promote orb | ||
orb-name: roopakv/swissknife | ||
cleanup-tags: true | ||
ssh-fingerprints: 39:1e:f6:7e:f0:aa:db:10:4e:84:30:6d:9c:dc:90:9e | ||
add-pr-comment: false | ||
requires: | ||
- publish-approval | ||
filters: | ||
branches: | ||
ignore: /.*/ | ||
tags: | ||
only: /master-major.*/ | ||
only: /.*-release.*/ | ||
|
||
executors: | ||
nodeimg: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
|
||
circleci config pack src > orb.yml | ||
circleci orb pack src > orb.yml | ||
circleci orb publish orb.yml roopakv/swissknife@dev:alpha | ||
rm -rf orb.yml | ||
rm -rf orb.yml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
if [ -z "$BASH" ]; then | ||
echo Bash not installed. | ||
exit 1 | ||
fi | ||
git status >/dev/null 2>&1 || { echo >&2 "Not in a git directory or no git"; exit 1; } | ||
circleci-agent >/dev/null 2>&1 || { echo >&2 "No Circle CI agent. These are in all Circle CI containers"; exit 1; } | ||
if [[ "$CIRCLE_TOKEN" == "" ]]; then | ||
echo "CIRCLE_TOKEN not set. Set a token to access the circle API in the env var CIRCLE_TOKEN"; | ||
exit 1; | ||
fi | ||
|
||
mkdir -p /tmp/swissknife/ | ||
|
||
cat > /tmp/swissknife/trigger_pipeline.sh \<<'EOF' | ||
#!/bin/bash -x | ||
echo "----------------------------------------" | ||
echo "Triggering Pipeline" | ||
|
||
export vcs_type="$1"; | ||
export username="$2"; | ||
export reponame="$3"; | ||
export branch="$4"; | ||
export params="$5"; | ||
|
||
trigger_workflow() { | ||
curl --silent -X POST \ | ||
"https://circleci.com/api/v2/project/$vcs_type/$username/$reponame/pipeline?circle-token=${CIRCLE_TOKEN}" \ | ||
-H 'Accept: */*' \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"branch": "'$branch'", | ||
"parameters": '"$params"' | ||
}' | ||
} | ||
|
||
trigger_workflow | ||
|
||
echo "Finished triggering pipeline" | ||
echo "----------------------------------------" | ||
EOF | ||
|
||
chmod +x /tmp/swissknife/trigger_pipeline.sh | ||
|
||
if [[ "<< parameters.install-skip-trigger >>" == "false" ]]; then | ||
/tmp/swissknife/trigger_pipeline.sh << parameters.vcs-type >> $<< parameters.user >> $<< parameters.repo-name >> $<< parameters.branch >> '<< parameters.custom-parameters >>' | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
description: | | ||
Triggers a pipeline on given branch. Also allows to installthe trigger script and not trigger into | ||
/tmp/swissknife/trigger_pipeline.sh | ||
it can be called with the arguments as follows | ||
/tmp/swissknife/trigger_pipeline.sh vcstype username reponame branch '{"custom_params": "here"}' | ||
parameters: | ||
repo-name: | ||
type: env_var_name | ||
description: The repo to trigger the workflow on | ||
default: CIRCLE_PROJECT_REPONAME | ||
user: | ||
description: Username for the Github Project | ||
type: env_var_name | ||
default: CIRCLE_PROJECT_USERNAME | ||
vcs-type: | ||
description: What is the VCS for this project | ||
type: string | ||
default: github | ||
branch: | ||
description: The branch to trigger the pipeline on | ||
type: env_var_name | ||
default: CIRCLE_BRANCH | ||
custom-parameters: | ||
description: Custom parameters passed to the pipeline | ||
type: string | ||
default: "{}" | ||
install-skip-trigger: | ||
description: Adds the script to /tmp/swissknife/trigger_pipeline.sh and don't trigger flow | ||
type: boolean | ||
default: false | ||
steps: | ||
- run: | ||
name: Trigger pipeline | ||
command: << include(../scripts/trigger-pipeline.sh) >> |