Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active January 18, 2022 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vfarcic/db86e33ed393edc595176787712bcd92 to your computer and use it in GitHub Desktop.
Save vfarcic/db86e33ed393edc595176787712bcd92 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/db86e33ed393edc595176787712bcd92
# Links to gists for creating a cluster with jx
# gke-jx-serverless.sh: https://gist.github.com/fe18870a015f4acc34d91c106d0d43c8
# eks-jx-serverless.sh: https://gist.github.com/f4a1df244d1852ee250e751c7191f5bd
# aks-jx-serverless.sh: https://gist.github.com/b07f45f6907c2a1c71f45dbe0df8d410
# install-serverless.sh: https://gist.github.com/7b3b3d90ecd7f343effe4fff5241d037
cd go-demo-6
git pull
git checkout extension-tekton
git merge -s ours master --no-edit
git checkout master
git merge extension-tekton
git push
cd ..
cd go-demo-6
# If GKE
export REGISTRY_OWNER=$PROJECT
# If EKS or AKS
# Replace `[...]` with your GitHub user
export REGISTRY_OWNER=[...]
cat charts/go-demo-6/Makefile \
| sed -e \
"s@vfarcic@$REGISTRY_OWNER@g" \
| sed -e \
"s@devops-26@$REGISTRY_OWNER@g" \
| tee charts/go-demo-6/Makefile
cat charts/preview/Makefile \
| sed -e \
"s@vfarcic@$REGISTRY_OWNER@g" \
| sed -e \
"s@devops-26@$REGISTRY_OWNER@g" \
| tee charts/preview/Makefile
cat skaffold.yaml \
| sed -e \
"s@vfarcic@$REGISTRY_OWNER@g" \
| sed -e \
"s@devops-26@$REGISTRY_OWNER@g" \
| tee skaffold.yaml
cd ..
cd go-demo-6
jx import --pack go --batch-mode
cd ..
cd go-demo-6
cat jenkins-x.yml
git checkout -b better-pipeline
echo "buildPack: go
pipelineConfig:
pipelines:
pullRequest:
build:
preSteps:
# This was modified
- name: unit-tests
command: make unittest
promote:
steps:
# This is new
- name: rollout
command: |
NS=\`echo jx-\$REPO_OWNER-go-demo-6-\$BRANCH_NAME | tr '[:upper:]' '[:lower:]'\`
sleep 15
kubectl -n \$NS rollout status deployment preview-preview --timeout 3m
# This was modified
- name: functional-tests
command: ADDRESS=\`jx get preview --current 2>&1\` make functest
" | tee jenkins-x.yml
jx step syntax validate pipeline
git add .
git commit -m "rollout status"
git push --set-upstream origin \
better-pipeline
jx create pullrequest \
--title "Better pipeline" \
--body "What I can say?" \
--batch-mode
export BRANCH=[...] # e.g., PR-72
jx get activities \
--filter go-demo-6/$BRANCH \
--watch
jx get build logs --current
curl -o Makefile \
https://gist.githubusercontent.com/vfarcic/313bedd36e863249cb01af1f459139c7/raw
open "https://codecov.io/"
export CODECOV_TOKEN=[...]
open "https://github.com/vfarcic/codecov"
echo "buildPack: go
pipelineConfig:
# This is new
env:
- name: CODECOV_TOKEN
value: \"$CODECOV_TOKEN\"
pipelines:
pullRequest:
build:
preSteps:
- name: unit-tests
command: make unittest
# This is new
- name: code-coverage
command: codecov.sh
agent:
image: vfarcic/codecov
promote:
steps:
- name: rollout
command: |
NS=\`echo jx-\$REPO_OWNER-go-demo-6-\$BRANCH_NAME | tr '[:upper:]' '[:lower:]'\`
sleep 15
kubectl -n \$NS rollout status deployment preview-preview --timeout 3m
- name: functional-tests
command: ADDRESS=\`jx get preview --current 2>&1\` make functest
" | tee jenkins-x.yml
jx step syntax validate pipeline
git add .
git commit -m "Code coverage"
git push
jx get activities \
--filter go-demo-6/$BRANCH \
--watch
jx get build logs --current
kubectl create secret \
generic codecov \
--from-literal=token=$CODECOV_TOKEN
echo "buildPack: go
pipelineConfig:
env:
# This was modified
- name: CODECOV_TOKEN
valueFrom:
secretKeyRef:
key: token
name: codecov
pipelines:
pullRequest:
build:
preSteps:
- name: unit-tests
command: make unittest
- name: code-coverage
command: codecov.sh
agent:
image: vfarcic/codecov
promote:
steps:
- name: rollout
command: |
NS=\`echo jx-\$REPO_OWNER-go-demo-6-\$BRANCH_NAME | tr '[:upper:]' '[:lower:]'\`
sleep 15
kubectl -n \$NS rollout status deployment preview-preview --timeout 3m
- name: functional-tests
command: ADDRESS=\`jx get preview --current 2>&1\` make functest
" | tee jenkins-x.yml
jx step syntax validate pipeline
git add .
git commit -m "Code coverage secret"
git push
jx get activities \
--filter go-demo-6/$BRANCH \
--watch
git checkout master
git pull
git branch -d better-pipeline
echo "buildPack: go
pipelineConfig:
env:
- name: CODECOV_TOKEN
valueFrom:
secretKeyRef:
key: token
name: codecov
pipelines:
pullRequest:
build:
preSteps:
- name: unit-tests
command: make unittest
- name: code-coverage
command: codecov.sh
agent:
image: vfarcic/codecov
promote:
steps:
- name: rollout
command: |
NS=\`echo jx-\$REPO_OWNER-go-demo-6-\$BRANCH_NAME | tr '[:upper:]' '[:lower:]'\`
sleep 15
kubectl -n \$NS rollout status deployment preview-preview --timeout 3m
- name: functional-tests
command: ADDRESS=\`jx get preview --current 2>&1\` make functest
# This is new
overrides:
- pipeline: release
" | tee jenkins-x.yml
jx step syntax validate pipeline
git add .
git commit -m "Multi-architecture"
git push
jx get activities \
--filter go-demo-6/master \
--watch
echo "buildPack: go
pipelineConfig:
env:
- name: CODECOV_TOKEN
valueFrom:
secretKeyRef:
key: token
name: codecov
pipelines:
pullRequest:
build:
preSteps:
- name: unit-tests
command: make unittest
- name: code-coverage
command: codecov.sh
agent:
image: vfarcic/codecov
promote:
steps:
- name: rollout
command: |
NS=\`echo jx-\$REPO_OWNER-go-demo-6-\$BRANCH_NAME | tr '[:upper:]' '[:lower:]'\`
sleep 15
kubectl -n \$NS rollout status deployment preview-preview --timeout 3m
- name: functional-tests
command: ADDRESS=\`jx get preview --current 2>&1\` make functest
overrides:
- pipeline: release
# This is new
stage: build
# This is new
release:
promote:
steps:
- name: rollout
command: |
sleep 30
kubectl -n jx-staging rollout status deployment jx-go-demo-6 --timeout 3m
" | tee jenkins-x.yml
jx step syntax validate pipeline
git add .
git commit -m "Multi-architecture"
git push
jx get activities \
--filter go-demo-6/master \
--watch
echo "buildPack: go
pipelineConfig:
env:
- name: CODECOV_TOKEN
valueFrom:
secretKeyRef:
key: token
name: codecov
pipelines:
pullRequest:
build:
preSteps:
- name: unit-tests
command: make unittest
- name: code-coverage
command: codecov.sh
agent:
image: vfarcic/codecov
promote:
steps:
- name: rollout
command: |
NS=\`echo jx-\$REPO_OWNER-go-demo-6-\$BRANCH_NAME | tr '[:upper:]' '[:lower:]'\`
sleep 15
kubectl -n \$NS rollout status deployment preview-preview --timeout 3m
- name: functional-tests
command: ADDRESS=\`jx get preview --current 2>&1\` make functest
# Removed overrides
release:
promote:
steps:
- name: rollout
command: |
sleep 30
kubectl -n jx-staging rollout status deployment jx-go-demo-6 --timeout 3m
" | tee jenkins-x.yml
jx step syntax effective
echo "buildPack: go
pipelineConfig:
env:
- name: CODECOV_TOKEN
valueFrom:
secretKeyRef:
key: token
name: codecov
pipelines:
pullRequest:
build:
preSteps:
- name: unit-tests
command: make unittest
- name: code-coverage
command: codecov.sh
agent:
image: vfarcic/codecov
promote:
steps:
- name: rollout
command: |
NS=\`echo jx-\$REPO_OWNER-go-demo-6-\$BRANCH_NAME | tr '[:upper:]' '[:lower:]'\`
sleep 30
kubectl -n \$NS rollout status deployment preview-preview --timeout 3m
- name: functional-tests
command: ADDRESS=\`jx get preview --current 2>&1\` make functest
overrides:
- pipeline: release
# This is new
stage: build
name: make-build
steps:
- loop:
variable: GOOS
values:
- darwin
- linux
- windows
steps:
- name: build
command: CGO_ENABLED=0 GOOS=\${GOOS} GOARCH=amd64 go build -o bin/go-demo-6_\${GOOS} main.go
release:
promote:
steps:
- name: rollout
command: |
sleep 15
kubectl -n jx-staging rollout status deployment jx-go-demo-6 --timeout 3m
" | tee jenkins-x.yml
jx step syntax validate pipeline
cat Dockerfile
cat Dockerfile \
| sed -e \
's@/bin/ /@/bin/go-demo-6_linux /go-demo-6@g' \
| tee Dockerfile
git add .
git commit -m "Multi-architecture"
git push
jx get activities \
--filter go-demo-6/master \
--watch
echo "buildPack: none
pipelineConfig:
pipelines:
release:
pipeline:
agent:
image: go
stages:
- name: nothing
steps:
- name: silly
command: echo \"This is a silly pipeline\"" \
| tee jenkins-x.yml
git add .
git commit -m "Without buildpack"
git push
jx get activities \
--filter go-demo-6/master \
--watch
jx step syntax schema
jx step syntax schema --buildpack
jx step syntax validate buildpacks
git checkout extension-tekton
git merge -s ours master --no-edit
git checkout master
git merge extension-tekton
git push
cd ..
export GH_USER=[...]
hub delete -y \
$GH_USER/environment-jx-rocks-staging
hub delete -y \
$GH_USER/environment-jx-rocks-production
rm -rf ~/.jx/environments/$GH_USER/environment-jx-rocks-*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment