Skip to content

Commit 835c566

Browse files
committed
chore: Jenkins X build pack
1 parent dab992b commit 835c566

File tree

6 files changed

+586
-0
lines changed

6 files changed

+586
-0
lines changed

.lighthouse/jenkins-x/Kptfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: kpt.dev/v1alpha1
2+
kind: Kptfile
3+
metadata:
4+
name: jenkins-x
5+
upstream:
6+
type: git
7+
git:
8+
commit: 4b44dcda8284ebcecf7eed34c00f23b54e7a9d27
9+
repo: https://github.com/scheduleonce/jx3-pipeline-catalog
10+
directory: /packs/eslint-config-oncehub/.lighthouse/jenkins-x
11+
ref: master
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: PipelineRun
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
branch: master
7+
build: "1"
8+
jenkins.io/pipelineType: build
9+
owner: jenkins-x-quickstarts
10+
repository: eslint-config-oncehub
11+
name: eslint-pr
12+
spec:
13+
pipelineSpec:
14+
params:
15+
- description: the unique build number
16+
name: BUILD_ID
17+
type: string
18+
- description: the name of the job which is the trigger context name
19+
name: JOB_NAME
20+
type: string
21+
- description: the specification of the job
22+
name: JOB_SPEC
23+
type: string
24+
- description: 'the kind of job: postsubmit or presubmit'
25+
name: JOB_TYPE
26+
type: string
27+
- default: master
28+
description: the base git reference of the pull request
29+
name: PULL_BASE_REF
30+
type: string
31+
- description: the git sha of the base of the pull request
32+
name: PULL_BASE_SHA
33+
type: string
34+
- default: ""
35+
description: git pull request number
36+
name: PULL_NUMBER
37+
type: string
38+
- default: ""
39+
description: git pull request ref in the form 'refs/pull/$PULL_NUMBER/head'
40+
name: PULL_PULL_REF
41+
type: string
42+
- default: master
43+
description: git revision to checkout (branch, tag, sha, ref…)
44+
name: PULL_PULL_SHA
45+
type: string
46+
- description: git pull reference strings of base and latest in the form 'master:$PULL_BASE_SHA,$PULL_NUMBER:$PULL_PULL_SHA:refs/pull/$PULL_NUMBER/head'
47+
name: PULL_REFS
48+
type: string
49+
- description: git repository name
50+
name: REPO_NAME
51+
type: string
52+
- description: git repository owner (user or organisation)
53+
name: REPO_OWNER
54+
type: string
55+
- description: git url to clone
56+
name: REPO_URL
57+
type: string
58+
tasks:
59+
- name: eslint-pr
60+
params:
61+
- name: BUILD_ID
62+
value: $(params.BUILD_ID)
63+
- name: JOB_NAME
64+
value: $(params.JOB_NAME)
65+
- name: JOB_SPEC
66+
value: $(params.JOB_SPEC)
67+
- name: JOB_TYPE
68+
value: $(params.JOB_TYPE)
69+
- name: PULL_BASE_REF
70+
value: $(params.PULL_BASE_REF)
71+
- name: PULL_BASE_SHA
72+
value: $(params.PULL_BASE_SHA)
73+
- name: PULL_NUMBER
74+
value: $(params.PULL_NUMBER)
75+
- name: PULL_PULL_REF
76+
value: $(params.PULL_PULL_REF)
77+
- name: PULL_PULL_SHA
78+
value: $(params.PULL_PULL_SHA)
79+
- name: PULL_REFS
80+
value: $(params.PULL_REFS)
81+
- name: REPO_NAME
82+
value: $(params.REPO_NAME)
83+
- name: REPO_OWNER
84+
value: $(params.REPO_OWNER)
85+
- name: REPO_URL
86+
value: $(params.REPO_URL)
87+
resources: {}
88+
taskSpec:
89+
params:
90+
- description: git url to clone
91+
name: REPO_URL
92+
type: string
93+
- default: master
94+
description: git revision to checkout (branch, tag, sha, ref…)
95+
name: PULL_PULL_SHA
96+
type: string
97+
- default: source
98+
description: subdirectory inside of /workspace to clone the git repo
99+
name: subdirectory
100+
type: string
101+
- description: the unique build number
102+
name: BUILD_ID
103+
type: string
104+
- description: the name of the job which is the trigger context name
105+
name: JOB_NAME
106+
type: string
107+
- description: the specification of the job
108+
name: JOB_SPEC
109+
type: string
110+
- description: 'the kind of job: postsubmit or presubmit'
111+
name: JOB_TYPE
112+
type: string
113+
- default: master
114+
description: the base git reference of the pull request
115+
name: PULL_BASE_REF
116+
type: string
117+
- description: the git sha of the base of the pull request
118+
name: PULL_BASE_SHA
119+
type: string
120+
- default: ""
121+
description: git pull request number
122+
name: PULL_NUMBER
123+
type: string
124+
- default: ""
125+
description: git pull request ref in the form 'refs/pull/$PULL_NUMBER/head'
126+
name: PULL_PULL_REF
127+
type: string
128+
- description: git pull reference strings of base and latest in the form 'master:$PULL_BASE_SHA,$PULL_NUMBER:$PULL_PULL_SHA:refs/pull/$PULL_NUMBER/head'
129+
name: PULL_REFS
130+
type: string
131+
- description: git repository name
132+
name: REPO_NAME
133+
type: string
134+
- description: git repository owner (user or organisation)
135+
name: REPO_OWNER
136+
type: string
137+
stepTemplate:
138+
env:
139+
- name: BUILD_ID
140+
value: $(params.BUILD_ID)
141+
- name: JOB_NAME
142+
value: $(params.JOB_NAME)
143+
- name: JOB_SPEC
144+
value: $(params.JOB_SPEC)
145+
- name: JOB_TYPE
146+
value: $(params.JOB_TYPE)
147+
- name: PULL_BASE_REF
148+
value: $(params.PULL_BASE_REF)
149+
- name: PULL_BASE_SHA
150+
value: $(params.PULL_BASE_SHA)
151+
- name: PULL_NUMBER
152+
value: $(params.PULL_NUMBER)
153+
- name: PULL_PULL_REF
154+
value: $(params.PULL_PULL_REF)
155+
- name: PULL_PULL_SHA
156+
value: $(params.PULL_PULL_SHA)
157+
- name: PULL_REFS
158+
value: $(params.PULL_REFS)
159+
- name: REPO_NAME
160+
value: $(params.REPO_NAME)
161+
- name: REPO_OWNER
162+
value: $(params.REPO_OWNER)
163+
- name: REPO_URL
164+
value: $(params.REPO_URL)
165+
- name: DOCKER_REGISTRY
166+
valueFrom:
167+
configMapKeyRef:
168+
name: jenkins-x-docker-registry
169+
key: docker.registry
170+
- name: DOCKER_REGISTRY_ORG
171+
value: "kubernetes"
172+
name: ""
173+
resources:
174+
requests:
175+
cpu: 400m
176+
memory: 512Mi
177+
volumeMounts:
178+
- mountPath: /home/jenkins
179+
name: workspace-volume
180+
- mountPath: /etc/podinfo
181+
name: podinfo
182+
readOnly: true
183+
- mountPath: /merge-disabled
184+
name: merge-disabled
185+
readOnly: true
186+
workingDir: /workspace/source
187+
steps:
188+
- script: |
189+
#!/usr/bin/env bash
190+
RED='\033[0;31m'
191+
NC='\033[0m' # No Color
192+
mergeDisabled=$(cat "/merge-disabled/MERGE_DISABLED")
193+
if [[ $(params.PULL_BASE_REF) == "qa" && $mergeDisabled == "true" ]]; then
194+
echo -e "\n ${RED}Merge is temporarly disabled for $(params.PULL_BASE_REF) branch...Please close/reopen the PR's once merge is enabled...${NC}"
195+
exit 1;
196+
fi
197+
image: ghcr.io/jenkins-x/builder-jx:2.1.155-779
198+
name: check-merge-disabled
199+
- args:
200+
- -c
201+
- 'mkdir -p $HOME; git config --global --add user.name ${GIT_AUTHOR_NAME:-so-integrations}; git config --global --add user.email ${GIT_AUTHOR_EMAIL:[email protected]}; git config --global credential.helper store; git clone $(params.REPO_URL) $(params.subdirectory); echo cloned url: $(params.REPO_URL) to dir: $(params.subdirectory);'
202+
command:
203+
- /bin/sh
204+
image: ghcr.io/jenkins-x/builder-jx:2.1.155-779
205+
name: git-clone
206+
resources: {}
207+
workingDir: /workspace
208+
- args:
209+
- '[ -d /builder/home ] || mkdir -p /builder && ln -s /tekton/home /builder/home'
210+
command:
211+
- /bin/sh
212+
- -c
213+
image: ghcr.io/jenkins-x/builder-jx:2.1.155-779
214+
name: setup-builder-home
215+
resources: {}
216+
- args:
217+
- step
218+
- git
219+
- merge
220+
- --verbose
221+
- --baseSHA
222+
- $(params.PULL_BASE_SHA)
223+
- --sha
224+
- $(params.PULL_PULL_SHA)
225+
- --baseBranch
226+
- $(params.PULL_BASE_REF)
227+
command:
228+
- jx
229+
image: ghcr.io/jenkins-x/builder-jx:2.1.155-779
230+
name: git-merge
231+
resources: {}
232+
- args:
233+
- -c
234+
- |
235+
/bin/bash <<'EOF'
236+
# Script to evaluate image tag.
237+
branchName=$PULL_BASE_REF
238+
echo "eval tag script for $branchName branch..."
239+
teamBranchReg="team\/.*"
240+
storyBranchReg=".*\/story\/.*"
241+
if [[ $branchName =~ $teamBranchReg ]]; then
242+
tag=$(echo $branchName | sed 's/team\//''/g' )
243+
elif [[ $branchName =~ $storyBranchReg ]]; then
244+
tag=$(echo $branchName | sed 's/\/.*/''/g' )
245+
elif [[ $branchName == "master" ]]; then
246+
tag="prod"
247+
elif [[ $branchName == "qa" || $branchName == "staging-app2" ]]; then
248+
tag=$branchName
249+
else
250+
tag="${branchName//\//'-'}"
251+
fi
252+
echo $tag > VERSION
253+
EOF
254+
command:
255+
- /bin/sh
256+
image: ghcr.io/jenkins-x/builder-go
257+
name: pr-version
258+
resources: {}
259+
volumes:
260+
- emptyDir: {}
261+
name: workspace-volume
262+
- downwardAPI:
263+
items:
264+
- fieldRef:
265+
fieldPath: metadata.labels
266+
path: labels
267+
name: podinfo
268+
- name: merge-disabled
269+
secret:
270+
secretName: merge-disabled
271+
podTemplate:
272+
ImagePullSecrets:
273+
- name: tekton-container-registry-auth
274+
hostNetwork: false
275+
schedulerName: ""
276+
serviceAccountName: tekton-bot
277+
timeout: 240h0m0s
278+
status: {}

0 commit comments

Comments
 (0)