-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs-tidb-operator): add docs tidb operator merged pipeline (#2918)
add docs tidb operator merged pipeline. --------- Signed-off-by: purelind <purelind@gmail.com>
- Loading branch information
Showing
6 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
folder('pingcap/docs-tidb-operator') { | ||
description("Folder for pipelines of pingcap/docs-tidb-operator repo") | ||
} |
38 changes: 38 additions & 0 deletions
38
jobs/pingcap/docs-tidb-operator/latest/merged_update.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// REF: https://<your-jenkins-server>/plugin/job-dsl/api-viewer/index.html | ||
// For trunk and latest release branches. | ||
pipelineJob('pingcap/docs-tidb-operator/merged_update') { | ||
logRotator { | ||
daysToKeep(30) | ||
} | ||
parameters { | ||
// Ref: https://docs.prow.k8s.io/docs/jobs/#job-environment-variables | ||
stringParam("BUILD_ID") | ||
stringParam("PROW_JOB_ID") | ||
stringParam("JOB_SPEC") | ||
} | ||
properties { | ||
githubProjectUrl("https://github.com/pingcap/docs-tidb-operator") | ||
} | ||
|
||
definition { | ||
cpsScm { | ||
lightweight(true) | ||
scriptPath("pipelines/pingcap/docs-tidb-operator/latest/merged_update.groovy") | ||
scm { | ||
git{ | ||
remote { | ||
url('https://github.com/PingCAP-QE/ci.git') | ||
} | ||
branch('main') | ||
extensions { | ||
cloneOptions { | ||
depth(1) | ||
shallow(true) | ||
timeout(5) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
pipelines/pingcap/docs-tidb-operator/latest/merged_update.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// REF: https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-pipeline | ||
// Keep small than 400 lines: https://issues.jenkins.io/browse/JENKINS-37984 | ||
// should triggerd for master and latest release branches | ||
@Library('tipipeline') _ | ||
|
||
final K8S_NAMESPACE = "jenkins-tidb" | ||
final GIT_FULL_REPO_NAME = 'pingcap/docs-tidb-operator' | ||
final POD_TEMPLATE_FILE = 'pipelines/pingcap/docs-tidb-operator/latest/pod-merged_update.yaml' | ||
final REFS = readJSON(text: params.JOB_SPEC).refs | ||
|
||
|
||
pipeline { | ||
agent { | ||
kubernetes { | ||
namespace K8S_NAMESPACE | ||
yamlFile POD_TEMPLATE_FILE | ||
defaultContainer 'runner' | ||
} | ||
} | ||
environment { | ||
FILE_SERVER_URL = 'http://fileserver.pingcap.net' | ||
} | ||
options { | ||
timeout(time: 45, unit: 'MINUTES') | ||
parallelsAlwaysFailFast() | ||
} | ||
stages { | ||
stage('Debug info') { | ||
steps { | ||
sh label: 'Debug info', script: """ | ||
printenv | ||
echo "-------------------------" | ||
python3 -V | ||
echo "-------------------------" | ||
echo "debug command: kubectl -n ${K8S_NAMESPACE} exec -ti ${NODE_NAME} bash" | ||
""" | ||
container(name: 'net-tool') { | ||
sh 'dig github.com' | ||
script { | ||
currentBuild.description = "branch ${REFS.base_ref}: ${REFS.base_sha}" | ||
} | ||
} | ||
} | ||
} | ||
stage('Checkout') { | ||
options { timeout(time: 10, unit: 'MINUTES') } | ||
steps { | ||
dir("docs-tidb-operator") { | ||
container(name: 'node') { | ||
sh label: "set git config", script: """ | ||
git config --global --add safe.directory '*' | ||
""" | ||
cache(path: "./", includes: '**/*', key: prow.getCacheKey('git', REFS), restoreKeys: prow.getRestoreKeys('git', REFS)) { | ||
retry(2) { | ||
script { | ||
prow.checkoutRefs(REFS) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
stage('Build pdf') { | ||
options { timeout(time: 45, unit: 'MINUTES') } | ||
|
||
steps { | ||
dir("docs-tidb-operator") { | ||
withCredentials([ | ||
string(credentialsId: 'docs-cn-aws-ak', variable: 'AWS_ACCESS_KEY'), | ||
string(credentialsId: 'docs-cn-aws-sk', variable: 'AWS_SECRET_KEY'), | ||
string(credentialsId: 'docs-cn-aws-region', variable: 'AWS_REGION'), | ||
string(credentialsId: 'docs-cn-aws-bn', variable: 'AWS_BUCKET_NAME'), | ||
string(credentialsId: 'docs-cn-qiniu-ak', variable: 'QINIU_ACCESS_KEY'), | ||
string(credentialsId: 'docs-cn-qiniu-sk', variable: 'QINIU_SECRET_KEY'), | ||
string(credentialsId: 'docs-cn-qiniu-bn', variable: 'QINIU_BUCKET_NAME') | ||
]){ | ||
// TODO: pre-install python3 packages(boto3, awscli) in the docker image | ||
sh label: 'Build pdf', script: """#!/usr/bin/env bash | ||
sudo pip3 install boto3 | ||
sudo pip3 install awscli | ||
printf "%s\n" ${AWS_ACCESS_KEY} ${AWS_SECRET_KEY} ${AWS_REGION} "json" | aws configure | ||
find -name '*.md' | xargs -d '\n' grep -P '\t' && exit 1 | ||
python3 scripts/merge_by_toc.py | ||
scripts/generate_pdf.sh | ||
""" | ||
// TODO: uncomment the following lines after the test is passed | ||
// sh label: 'Upload pdf', script: """#!/usr/bin/env bash | ||
// target_version=\$(echo ${REFS.base_ref} | sed 's/release-//') | ||
// if [ "${REFS.base_ref}" = "master" ]; then | ||
// python3 scripts/upload.py output_en.pdf tidb-in-kubernetes-dev-en-manual.pdf; | ||
// python3 scripts/upload.py output_zh.pdf tidb-in-kubernetes-dev-zh-manual.pdf; | ||
// elif [ "${REFS.base_ref}" = "release-1.5" ]; then | ||
// python3 scripts/upload.py output_en.pdf tidb-in-kubernetes-stable-en-manual.pdf; | ||
// python3 scripts/upload.py output_zh.pdf tidb-in-kubernetes-stable-zh-manual.pdf; | ||
// elif case "${REFS.base_ref}" in release-*) ;; *) false;; esac; then | ||
// python3 scripts/upload.py output_en.pdf tidb-in-kubernetes-v\${target_version}-en-manual.pdf; | ||
// python3 scripts/upload.py output_zh.pdf tidb-in-kubernetes-v\${target_version}-zh-manual.pdf; | ||
// fi | ||
// """ | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
pipelines/pingcap/docs-tidb-operator/latest/pod-merged_update.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
spec: | ||
securityContext: | ||
fsGroup: 1000 | ||
containers: | ||
- name: runner | ||
image: hub.pingcap.net/jenkins/docs-cn-checker:v0.0.1 | ||
tty: true | ||
resources: | ||
requests: | ||
memory: 12Gi | ||
cpu: "4" | ||
limits: | ||
memory: 12Gi | ||
cpu: "4" | ||
- name: node | ||
image: node:lts | ||
tty: true | ||
resources: | ||
requests: | ||
memory: 2Gi | ||
cpu: "1" | ||
limits: | ||
memory: 2Gi | ||
cpu: "1" | ||
- name: net-tool | ||
image: hub.pingcap.net/jenkins/network-multitool | ||
tty: true | ||
resources: | ||
limits: | ||
memory: 128Mi | ||
cpu: 100m | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: kubernetes.io/arch | ||
operator: In | ||
values: | ||
- amd64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# struct ref: https://pkg.go.dev/k8s.io/test-infra/prow/config#Presubmit | ||
postsubmits: | ||
pingcap/docs-tidb-operator: | ||
- name: pingcap/docs-tidb-operator/merged_update | ||
agent: jenkins | ||
decorate: false # need add this. | ||
context: docs-tidb-operator/merged-ci | ||
max_concurrency: 5 | ||
skip_report: true # change to false after test passed | ||
branches: | ||
- ^master$ | ||
- ^release-1\.[2-6]$ |