blob: 92db94c4f9cf0a01fe9ee5246912f97578eca313 [file] [log] [blame]
Zack Williamsa8f3b842018-05-04 17:21:13 -07001---
2# CORD helm chart publishing tasks
3
4- project:
5 name: helm-repo
6
7 # add repos that have documentation to the project list in both jobs
8 jobs:
9 - 'publish-helm-repo':
Luca Preteae7fc492018-12-13 16:00:37 -080010 project-regexp: '{helm-charts-projects-regexp}'
Zack Williamsa8f3b842018-05-04 17:21:13 -070011 branch-regexp: '{supported-branches-regexp}'
12
Zack Williamsa8f3b842018-05-04 17:21:13 -070013- job-template:
14 id: publish-helm-repo
15 name: 'publish-helm-repo'
Zack Williams66eef762018-05-07 17:06:03 -070016 description: |
17 Created by publish-helm-repo job-template from ci-management/jjb/helm.yaml
Zack Williamsa8f3b842018-05-04 17:21:13 -070018
19 triggers:
20 - cord-infra-gerrit-trigger-merge:
21 gerrit-server-name: '{gerrit-server-name}'
22 project-regexp: '{project-regexp}'
23 branch-regexp: '{branch-regexp}'
24 file-include-regexp: '{all-files-regexp}'
25 dependency-jobs: '{dependency-jobs}'
26
27 properties:
28 - cord-infra-properties:
29 build-days-to-keep: '{build-days-to-keep}'
30 artifact-num-to-keep: '{artifact-num-to-keep}'
31
32 wrappers:
33 - lf-infra-wrappers:
34 build-timeout: '{build-timeout}'
35 jenkins-ssh-credential: '{jenkins-ssh-credential}'
36
37 scm:
38 - lf-infra-gerrit-scm:
39 git-url: '$GIT_URL/$GERRIT_PROJECT'
Zack Williams58750872018-05-07 17:35:45 -070040 refspec: ''
Zack Williamsa8f3b842018-05-04 17:21:13 -070041 branch: '$GERRIT_BRANCH'
42 submodule-recursive: 'false'
Zack Williamscd3eb202018-10-02 14:33:13 -070043 choosing-strategy: 'gerrit'
Zack Williamsa8f3b842018-05-04 17:21:13 -070044 jenkins-ssh-credential: '{jenkins-ssh-credential}'
45
46 node: '{build-node}'
47 project-type: freestyle
48 concurrent: false
49
50 builders:
51 - shell: |
Zack Williams642e5f72018-06-05 13:24:13 -070052 #!/usr/bin/env bash
Zack Williamsbf4339c2018-08-13 07:49:45 -070053 set -eu -o pipefail
Zack Williams642e5f72018-06-05 13:24:13 -070054
Zack Williams79e756c2019-01-03 14:44:21 -070055 echo "git version: $(git --version)"
56
Zack Williamsd5ce0ea2019-01-02 11:49:17 -070057 # Configure git
58 git config --global user.email "do-not-reply@opencord.org"
59 git config --global user.name "Jenkins"
60
61 # Checkout 'cord-charts-repo' repo that contains updated charts
Zack Williamse76c6b42019-01-02 20:39:38 -070062 git clone ssh://jenkins@gerrit.opencord.org:29418/cord-charts-repo.git
Zack Williamsd5ce0ea2019-01-02 11:49:17 -070063
64 # Clone the `helm-repo-tools` which contains scripts
Zack Williamse76c6b42019-01-02 20:39:38 -070065 git clone ssh://jenkins@gerrit.opencord.org:29418/helm-repo-tools.git
Zack Williams642e5f72018-06-05 13:24:13 -070066
Zack Williams1ab88922019-05-22 15:43:23 -070067 # Setup helm and external repos
Zack Williamsa8f3b842018-05-04 17:21:13 -070068 helm init --client-only
Zack Williams1ab88922019-05-22 15:43:23 -070069 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com
Zack Williamsbf4339c2018-08-13 07:49:45 -070070 helm repo add rook-beta https://charts.rook.io/beta
Zack Williams1ab88922019-05-22 15:43:23 -070071 helm repo add cord https://charts.opencord.org
Luca Prete2ae90132018-12-13 17:14:01 -080072
Zack Williamse6856b82019-01-02 17:22:19 -070073 # Update the repo
Luca Prete2ae90132018-12-13 17:14:01 -080074 ./helm-repo-tools/helmrepo.sh
Zack Williams642e5f72018-06-05 13:24:13 -070075
Zack Williamsd5ce0ea2019-01-02 11:49:17 -070076 # Tag and push to git the charts repo
77 pushd cord-charts-repo
Zack Williamse6856b82019-01-02 17:22:19 -070078
Zack Williams79e756c2019-01-03 14:44:21 -070079 # only update if charts are changed
80 set +e
81 if git diff --exit-code index.yaml > /dev/null; then
82 echo "No changes to charts in patchset $GERRIT_CHANGE_NUMBER on project: $GERRIT_PROJECT, exiting."
83 exit 0
84 fi
85 set -e
86
Zack Williamsd5ce0ea2019-01-02 11:49:17 -070087 # version tag is the current date in RFC3339 format
88 NEW_VERSION=$(date -u +%Y%m%dT%H%M%SZ)
89
Zack Williamse6856b82019-01-02 17:22:19 -070090 # Add changes and create commit
91 git add -A
Zack Williams79e756c2019-01-03 14:44:21 -070092 git commit -m "Changed by CORD Jenkins publish-helm-repo job: $BUILD_NUMBER, for project: $GERRIT_PROJECT, patchset: $GERRIT_CHANGE_NUMBER"
Zack Williamse6856b82019-01-02 17:22:19 -070093
94 # create tag on new commit
95 git tag "$NEW_VERSION"
Zack Williamsd5ce0ea2019-01-02 11:49:17 -070096
97 echo "Tags including new tag:"
98 git tag -n
99
Zack Williamse76c6b42019-01-02 20:39:38 -0700100 # push new commit and tag back into repo
Zack Williams79e756c2019-01-03 14:44:21 -0700101 git push origin
102 git push origin "$NEW_VERSION"
Zack Williamsd5ce0ea2019-01-02 11:49:17 -0700103 popd
104
105 # Set up the ssh host keys for the docs host
106 mkdir -p ~/.ssh
107 echo '{docs-ssh-host-key}' >> ~/.ssh/known_hosts
108
109 # Copy updated repo to host
110 rsync -rvzh --delete-after --exclude=.git cord-charts-repo/ {docs-ssh-host}:/var/www/charts
Zack Williams642e5f72018-06-05 13:24:13 -0700111
Kailashe602fd12018-12-14 14:39:40 -0800112 publishers:
113 - email:
Zack Williamsd5ce0ea2019-01-02 11:49:17 -0700114 recipients: 'andy@opennetworking.org kailash@opennetworking.org luca@opennetworking.org teo@opennetworking.org saurav@opennetworking.org zdw@opennetworking.org'
Kailashe602fd12018-12-14 14:39:40 -0800115
Zack Williams99150c62019-07-02 13:44:30 -0700116# check helm charts with `helm lint --strict` and that charts version is
117# updated when the contents of a chart is modified.
118- job-template:
119 id: verify-helm-lint
120 name: 'verify_{project}_helm-lint'
121 description: |
122 Created by verify-helm-lint job-template from ci-management/jjb/lint.yaml
123
124 triggers:
125 - cord-infra-gerrit-trigger-patchset:
126 gerrit-server-name: '{gerrit-server-name}'
127 project-regexp: '^{project}$'
128 branch-regexp: '{branch-regexp}'
129 file-include-regexp: '{all-files-regexp}'
130 dependency-jobs: '{dependency-jobs}'
131
132 properties:
133 - cord-infra-properties:
134 build-days-to-keep: '{build-days-to-keep}'
135 artifact-num-to-keep: '{artifact-num-to-keep}'
136
137 wrappers:
138 - lf-infra-wrappers:
139 build-timeout: '{build-timeout}'
140 jenkins-ssh-credential: '{jenkins-ssh-credential}'
141
142 scm:
143 - lf-infra-gerrit-scm:
144 git-url: '$GIT_URL/$GERRIT_PROJECT'
145 refspec: '$GERRIT_REFSPEC'
146 branch: '$GERRIT_BRANCH'
147 submodule-recursive: 'false'
148 choosing-strategy: gerrit
149 jenkins-ssh-credential: '{jenkins-ssh-credential}'
150
151 node: '{build-node}'
152 project-type: freestyle
153 concurrent: true
154
155 builders:
156 - shell: |
157 #!/usr/bin/env bash
158 set -eu -o pipefail
159
160 # Setup helm and external repos
161 helm init --client-only
162 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com
163 helm repo add rook-beta https://charts.rook.io/beta
164 helm repo add cord https://charts.opencord.org
165
166 git clone https://gerrit.opencord.org/helm-repo-tools
167 ./helm-repo-tools/helmlint.sh clean
168
169 # Specify the remote branch to compare against
170 export COMPARISON_BRANCH="origin/$GERRIT_BRANCH"
171 ./helm-repo-tools/chart_version_check.sh
172
173 # Check for chart version conflicts by building the repo (don't upload)
174 git clone ssh://jenkins@gerrit.opencord.org:29418/cord-charts-repo.git
175 ./helm-repo-tools/helmrepo.sh