Skip to content

Commit

Permalink
feat(docs-tidb-operator): add docs tidb operator merged pipeline (#2918)
Browse files Browse the repository at this point in the history
add docs tidb operator merged pipeline.

---------

Signed-off-by: purelind <purelind@gmail.com>
  • Loading branch information
purelind committed Apr 16, 2024
1 parent 6815a11 commit 3b11621
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jobs/pingcap/docs-tidb-operator/aa_folder.groovy
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 jobs/pingcap/docs-tidb-operator/latest/merged_update.groovy
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 pipelines/pingcap/docs-tidb-operator/latest/merged_update.groovy
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 pipelines/pingcap/docs-tidb-operator/latest/pod-merged_update.yaml
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
1 change: 1 addition & 0 deletions prow-jobs/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ configMapGenerator:
- pingcap-docs-postsubmits.yaml
- pingcap-docs-cn-latest-presubmits.yaml
- pingcap-docs-latest-presubmits.yaml
- pingcap-docs-tidb-operator-postsubmits.yaml
- pingcap-inc-enterprise-extensions-postsubmits.yaml
- pingcap-inc-enterprise-extensions-presubmits.yaml
- pingcap-monitoring-periodics.yaml
Expand Down
12 changes: 12 additions & 0 deletions prow-jobs/pingcap-docs-tidb-operator-postsubmits.yaml
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]$

0 comments on commit 3b11621

Please sign in to comment.