Skip to content

Commit

Permalink
configure default parameters via envs in Jenkins job
Browse files Browse the repository at this point in the history
  • Loading branch information
cofyc committed Mar 19, 2020
1 parent d1afdab commit 3ac0041
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 13 deletions.
34 changes: 28 additions & 6 deletions ci/e2e_eks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ spec:
emptyDir: {}
'''

// Able to override default values in Jenkins job via environment variables.
if (!env.DEFAULT_GIT_REF) {
env.DEFAULT_GIT_REF = "master"
}

if (!env.DEFAULT_GINKGO_NODES) {
env.DEFAULT_GINKGO_NODES = "8"
}

if (!env.DEFAULT_E2E_ARGS) {
env.DEFAULT_E2E_ARGS = "--ginkgo.skip='\\[Serial\\]|\\[Stability\\]' --ginkgo.focus='\\[tidb-operator\\]'"
}

if (!env.DEFAULT_CLUSTER) {
env.DEFAULT_CLUSTER = "jenkins-tidb-operator-e2e"
}

if (!env.DEFAULT_AWS_REGION) {
env.DEFAULT_AWS_REGION = "us-west-2"
}

pipeline {
agent {
kubernetes {
Expand All @@ -50,16 +71,17 @@ pipeline {
}

options {
timeout(time: 3, unit: 'HOURS')
timeout(time: 3, unit: 'HOURS')
}

parameters {
string(name: 'GIT_URL', defaultValue: '[email protected]:pingcap/tidb-operator.git', description: 'git repo url')
string(name: 'GIT_REF', defaultValue: 'master', description: 'git ref spec to checkout, e.g. master, release-1.1')
string(name: 'GIT_REF', defaultValue: env.DEFAULT_GIT_REF, description: 'git ref spec to checkout, e.g. master, release-1.1')
string(name: 'PR_ID', defaultValue: '', description: 'pull request ID, this will override GIT_REF if set, e.g. 1889')
string(name: 'CLUSTER', defaultValue: 'jenkins-tidb-operator-e2e', description: 'the name of the cluster')
string(name: 'AWS_REGION', defaultValue: 'us-west-2', description: 'the AWS region')
string(name: 'GINKGO_NODES', defaultValue: '8', description: 'the number of ginkgo nodes')
string(name: 'GINKGO_NODES', defaultValue: env.DEFAULT_GINKGO_NODES, description: 'the number of ginkgo nodes')
string(name: 'E2E_ARGS', defaultValue: env.DEFAULT_E2E_ARGS, description: "e2e args, e.g. --ginkgo.focus='\\[Stability\\]'")
string(name: 'CLUSTER', defaultValue: env.DEFAULT_CLUSTER, description: 'the name of the cluster')
string(name: 'AWS_REGION', defaultValue: env.DEFAULT_AWS_REGION, description: 'the AWS region')
}

environment {
Expand Down Expand Up @@ -117,7 +139,7 @@ pipeline {
echo "info: try to clean the cluster created previously"
./ci/aws-clean-eks.sh \$CLUSTER
echo "info: begin to run e2e"
./hack/e2e.sh -- --ginkgo.skip='\\[Serial\\]' --ginkgo.focus='\\[tidb-operator\\]'
./hack/e2e.sh -- ${params.E2E_ARGS}
"""
}
}
Expand Down
40 changes: 33 additions & 7 deletions ci/e2e_gke.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,31 @@ spec:
emptyDir: {}
'''

// Able to override default values in Jenkins job via environment variables.
if (!env.DEFAULT_GIT_REF) {
env.DEFAULT_GIT_REF = "master"
}

if (!env.DEFAULT_GINKGO_NODES) {
env.DEFAULT_GINKGO_NODES = "8"
}

if (!env.DEFAULT_E2E_ARGS) {
env.DEFAULT_E2E_ARGS = "--ginkgo.skip='\\[Serial\\]|\\[Stability\\]' --ginkgo.focus='\\[tidb-operator\\]'"
}

if (!env.DEFAULT_CLUSTER) {
env.DEFAULT_CLUSTER = "jenkins-tidb-operator-e2e"
}

if (!env.DEFAULT_GCP_PROJECT) {
env.DEFAULT_GCP_PROJECT = ""
}

if (!env.DEFAULT_GCP_ZONE) {
env.DEFAULT_GCP_ZONE = "us-central1-b"
}

pipeline {
agent {
kubernetes {
Expand All @@ -50,17 +75,18 @@ pipeline {
}

options {
timeout(time: 3, unit: 'HOURS')
timeout(time: 3, unit: 'HOURS')
}

parameters {
string(name: 'GIT_URL', defaultValue: '[email protected]:pingcap/tidb-operator.git', description: 'git repo url')
string(name: 'GIT_REF', defaultValue: 'master', description: 'git ref spec to checkout, e.g. master, release-1.1')
string(name: 'GIT_REF', defaultValue: env.DEFAULT_GIT_REF, description: 'git ref spec to checkout, e.g. master, release-1.1')
string(name: 'PR_ID', defaultValue: '', description: 'pull request ID, this will override GIT_REF if set, e.g. 1889')
string(name: 'CLUSTER', defaultValue: 'jenkins-tidb-operator-e2e', description: 'the name of the cluster')
string(name: 'GCP_PROJECT', defaultValue: 'smooth-tendril-207212', description: 'the GCP project ID')
string(name: 'GCP_ZONE', defaultValue: 'us-central1-b', description: 'the GCP zone')
string(name: 'GINKGO_NODES', defaultValue: '8', description: 'the number of ginkgo nodes')
string(name: 'GINKGO_NODES', defaultValue: env.DEFAULT_GINKGO_NODES, description: 'the number of ginkgo nodes')
string(name: 'E2E_ARGS', defaultValue: env.DEFAULT_E2E_ARGS, description: "e2e args, e.g. --ginkgo.focus='\\[Stability\\]'")
string(name: 'CLUSTER', defaultValue: env.DEFAULT_CLUSTER, description: 'the name of the cluster')
string(name: 'GCP_PROJECT', defaultValue: env.DEFAULT_GCP_PROJECT, description: 'the GCP project ID')
string(name: 'GCP_ZONE', defaultValue: env.DEFAULT_GCP_ZONE, description: 'the GCP zone')
}

environment {
Expand Down Expand Up @@ -120,7 +146,7 @@ pipeline {
echo "info: try to clean the cluster created previously"
SKIP_BUILD=y SKIP_IMAGE_BUILD=y SKIP_UP=y SKIP_TEST=y ./hack/e2e.sh
echo "info: begin to run e2e"
./hack/e2e.sh -- --ginkgo.skip='\\[Serial\\]' --ginkgo.focus='\\[tidb-operator\\]'
./hack/e2e.sh -- ${params.E2E_ARGS}
"""
}
}
Expand Down

0 comments on commit 3ac0041

Please sign in to comment.