Skip to content

Commit

Permalink
Merge pull request #70 from xuzhu-591/feat-when-expression
Browse files Browse the repository at this point in the history
feat: when exp
  • Loading branch information
xuzhu-591 authored Aug 10, 2023
2 parents 258c723 + 735563c commit a0bee70
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
4 changes: 2 additions & 2 deletions charts/horizon/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A CICD DevOps Platform

type: application

version: 2.2.11
version: 2.2.12
appVersion: v2.5.0
dependencies:
- name: common
Expand All @@ -20,7 +20,7 @@ dependencies:
- full

- name: tektoncd
version: 2.1.2
version: 2.1.3
repository: https://horizoncd.github.io/helm-charts
condition: tektoncd.enabled
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ spec:
- name: build
taskRef:
name: horizon-build
when:
{{- toYaml .Values.horizon.buildTask.whenExpression | nindent 8 }}
params:
- name: token
value: $(params.token)
Expand Down Expand Up @@ -82,6 +84,8 @@ spec:
- name: check
taskRef:
name: horizon-check
when:
{{- toYaml .Values.horizon.checkTask.whenExpression | nindent 8 }}
runAfter:
- build
params:
Expand Down
37 changes: 13 additions & 24 deletions charts/horizon/charts/tektonci-resources/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ horizon:
gitStep: 5m
compileStep:
imageStep: 60m
whenExpression:
- input: "$(params.action)"
operator: in
values:
- "builddeploy"
checkTask:
image:
checkStep: horizoncd/base-bash:v1.1.0
timeout:
checkStep: 2m
whenExpression:
- input: "$(params.imageURL)"
operator: notin
values:
- ""
deployTask:
image:
deployStep: horizoncd/base-bash:v1.0.0
Expand All @@ -34,20 +44,16 @@ horizon:
#!/bin/bash
set -e
export ACTION="$(params.action)"
if [[ "$ACTION" == "deploy" ]]
then
exit 0
fi
export SOURCE_DIR="/workspace/git-source"
export GIT_TOKENS_DIR="/workspace/git-token"
export GIT_REPOSITORY_URL="$(params.gitRepositoryUrl)"
export GIT_COMMIT="$(params.gitCommit)"
export GIT_PULL_URL=""
# config git ssh
rm -rf /root/.ssh && ln -s /tekton/home/.ssh /root
if [ ! -d /root/.ssh ] && [ -d /tekton/home/.ssh ]; then
rm -rf /root/.ssh && ln -s /tekton/home/.ssh /root
fi
if [ -f "/root/.ssh/config" ]; then
echo -e 'Host *\n StrictHostKeyChecking no' >> /root/.ssh/config
fi
Expand Down Expand Up @@ -90,12 +96,6 @@ horizon:
#!/bin/bash
set -e
export ACTION="$(params.action)"
if [[ "$ACTION" == "deploy" ]]
then
exit 0
fi
export GIT_SUBFOLDER="$(params.gitSubfolder)"
export PIPELINE_JSON_BLOB='$(params.pipelineJSONBlob)'
export DOCKERFILE_BUILD="dockerfile"
Expand Down Expand Up @@ -164,12 +164,6 @@ horizon:
#!/bin/bash
set -e
export ACTION="$(params.action)"
if [[ "$ACTION" == "deploy" ]]
then
exit 0
fi
export BUILD_TYPE="$(cat $(workspaces.buildinfo.path)/build-type)"
export APPLICATION="$(params.application)"
Expand Down Expand Up @@ -209,11 +203,6 @@ horizon:
export GIT_REPOSITORY_URL="$(params.gitRepositoryUrl)"
export IMAGE_URL="$(params.imageURL)"
if [ -z $IMAGE_URL ]; then
echo "there's no image found, skipping..."
exit 0
fi
is_json(){
local INPUT="$1"
[[ ! -z "$(jq -c "objects"<<<"$INPUT" 2>/dev/null)" ]] && return 0 || return 1
Expand Down

0 comments on commit a0bee70

Please sign in to comment.