I’m in the middle of transitioning a job-triggering strategy to a pipeline-triggering strategy.
It took me a while to figure out how to declare variables.
Note: I understand that I need to change the env var references in my “command” to the new << >> params syntax. My question is: why doesn’t the UI show my pipeline triggering?
I’m testing this on a branch: new_circle_config
version: 2.1
parameters:
# We must declare parameters that we intend to POST from the API.
# https://circleci.com/docs/2.0/reusing-config/#parameter-syntax
#
# We specify dummy sentinal values for the defaults. The API seems to complain
# if there are no defaults, but we really need to have these explicitly passed
# by our caller in every case. Instead, we check for "xxx" and bail if we see
# that in any parameter.
# https://circleci.com/gh/paperlesspost/kubernetes-deployments/131
NAMESPACE:
type: string
default: "xxx"
SERVICE:
type: string
default: "xxx"
VALUE:
type: string
default: "xxx"
VALUES_PATH:
type: string
default: "xxx"
jobs:
argo-release:
docker:
- image: "quay.io/paperlesspost/argo-repo:latest"
auth:
username: ${QUAY_USER}
password: ${QUAY_PASSWORD}
steps:
- add_ssh_keys:
fingerprints:
- "7a:55:30:73:dd:0e:75:1a:82:e4:d8:a9:c3:e1:7c:5f"
- checkout
- run:
name: Commit changes to kubernetes-deployments
command: |
[[ $NAMESPACE == "xxx" ]] && echo "must provide a NAMESPACE parameter!" && exit 1
[[ $SERVICE == "xxx" ]] && echo "must provide a SERVICE parameter!" && exit 1
[[ $VALUE == "xxx" ]] && echo "must provide a VALUE parameter!" && exit 1
[[ $VALUES_PATH == "xxx" ]] && echo "must provide a VALUES_PATH parameter!" && exit 1
argo-repo set --checkout-dir $(pwd) \
--namespace $NAMESPACE --service $SERVICE \
--values-path $VALUES_PATH --value $VALUE
promote-from-namespace:
docker:
- image: "quay.io/paperlesspost/argo-repo:latest"
auth:
username: ${QUAY_USER}
password: ${QUAY_PASSWORD}
steps:
- add_ssh_keys:
fingerprints:
- "7a:55:30:73:dd:0e:75:1a:82:e4:d8:a9:c3:e1:7c:5f"
- checkout
- run:
name: Get a value from an existing namespace and set it in another
command: |
[[ $NAMESPACE == "xxx" ]] && echo "must provide a NAMESPACE parameter!" && exit 1
[[ $SERVICE == "xxx" ]] && echo "must provide a SERVICE parameter!" && exit 1
TAG=$(argo-repo --checkout-dir $(pwd) get --namespace $FROM_NAMESPACE --service $SERVICE --values-path pp-service.image.tag)
echo "Copying existing tag $TAG from namespace $FROM_NAMESPACE to namespace $TO_NAMESPACE"
argo-repo set --checkout-dir $(pwd) --namespace $TO_NAMESPACE --service $SERVICE --values-path pp-service.image.tag --value $TAG
workflows:
version: 2
workflow:
jobs:
- argo-release:
filters:
branches:
ignore: /.*/
I trigger with this script:
#!/bin/bash
curl -X POST \
-u ${CIRCLE_API_TOKEN}: \
--header 'Content-Type: application/json' \
-d '{
"branch": "new_circle_config",
"parameters": {
"NAMESPACE": "development",
"SERVICE": "chartmuseum",
"VALUE": "55Mi",
"VALUES_PATH": "pp-service.resources.limits.memory"
}
}' https://circleci.com/api/v2/project/gh/paperlesspost/kubernetes-deployments/pipeline
The API responds with a new “pending” job.
The UI adds a new blank line, but shows nothing else to me. It doesn’t look right.