diff --git a/docs/docs/articles/cicd-overview.md b/docs/docs/articles/cicd-overview.md index 45142cbd97d..4a4d6c7213f 100644 --- a/docs/docs/articles/cicd-overview.md +++ b/docs/docs/articles/cicd-overview.md @@ -8,6 +8,7 @@ We have different tutorials for the options of being CI driven or using GitOps a - [Github Actions - running Testkube CLI commands with setup-testkube-action](./github-actions.md) - [Testkube Docker CLI](./testkube-cli-docker.md) - [Gitlab CI](./gitlab.md) +- [Jenkins](./jenkins.md) - [CircleCI](./circleci.md) - [GitOps Testing](./gitops-overview.md) - [Flux](./flux-integration.md) diff --git a/docs/docs/articles/jenkins.md b/docs/docs/articles/jenkins.md index 19ef0723a7b..30fe6343753 100644 --- a/docs/docs/articles/jenkins.md +++ b/docs/docs/articles/jenkins.md @@ -3,6 +3,11 @@ The Testkube Jenkins integration streamlines the installation of Testkube, enabling the execution of any [Testkube CLI](https://docs.testkube.io/cli/testkube) command within Jenkins pipelines. This integration can be effortlessly integrated into your Jenkins setup, enhancing your continuous integration and delivery processes. This Jenkins integration offers a versatile solution for managing your pipeline workflows and is compatible with Testkube Pro, Testkube Enterprise, and the open-source Testkube platform. It allows Jenkins users to effectively utilize Testkube's capabilities within their CI/CD pipelines, providing a robust and flexible framework for test execution and automation. +### Testkube CLI Jenkins Plugin + +Install the Testkube CLI plugin by searching it in the "Available Plugins" section on Jenkins Plugins, or using the following url: +[https://plugins.jenkins.io/testkube-cli](https://plugins.jenkins.io/testkube-cli) + ## Testkube Pro ### How to configure Testkube CLI action for Testkube Pro and run a test @@ -12,39 +17,31 @@ Then, pass the **organization** and **environment** IDs, along with the **token* If a test is already created, you can run it using the command `testkube run test test-name -f` . However, if you need to create a test in this workflow, please add a creation command, e.g.: `testkube create test --name test-name --file path_to_file.json`. -you'll need to create a Jenkinsfile. This Jenkinsfile should define the stages and steps necessary to execute the workflow +You'll need to create a Jenkinsfile. This Jenkinsfile should define the stages and steps necessary to execute the workflow ```groovy pipeline { agent any + environment { + TK_ORG = credentials("TK_ORG") + TK_ENV = credentials("TK_ENV") + TK_API_TOKEN = credentials("TK_API_TOKEN") + } stages { - stage('Setup Testkube') { + stage('Example') { steps { script { - // Retrieve credentials - def apiKey = credentials('TESTKUBE_API_KEY') - def orgId = credentials('TESTKUBE_ORG_ID') - def envId = credentials('TESTKUBE_ENV_ID') - - // Install Testkube - sh 'curl -sSLf https://get.testkube.io | sh' - - // Initialize Testkube - sh "testkube set context --api-key ${apiKey} --org ${orgId} --env ${envId}" + // Setup the Testkube CLI + setupTestkube() + // Run testkube commands + sh 'testkube run test your-test' + sh 'testkube run testsuite your-test-suite --some-arg --other-arg' } } } - - stage('Run Testkube Test') { - steps { - // Run a Testkube test - sh 'testkube run test test-name -f' - } - } } } - ``` ## Testkube OSS @@ -61,28 +58,18 @@ you'll need to create a Jenkinsfile. This Jenkinsfile should define the stages a pipeline { agent any + environment { + TK_NAMESPACE = 'custom-testkube-namespace' + } stages { - stage('Setup Testkube') { + stage('Example') { steps { script { - // Retrieve credentials - def namespace='custom-testkube' - - // Install Testkube - sh 'curl -sSLf https://get.testkube.io | sh' - - // Initialize Testkube - sh "testkube set context --kubeconfig --namespace ${namespace}" + setupTestkube() + sh 'testkube run test your-test' } } } - - stage('Run Testkube Test') { - steps { - // Run a Testkube test - sh 'testkube run test test-name -f' - } - } } } ``` @@ -104,6 +91,11 @@ you'll need to create a Jenkinsfile. This Jenkinsfile should define the stages a pipeline { agent any + environment { + TK_ORG = credentials("TK_ORG") + TK_ENV = credentials("TK_ENV") + TK_API_TOKEN = credentials("TK_API_TOKEN") + } stages { stage('Setup Testkube') { steps { @@ -120,17 +112,8 @@ pipeline { sh 'aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region $AWS_REGION' } - // Installing Testkube - sh 'curl -sSLf https://get.testkube.io | sh' - - // Initializing Testkube - withCredentials([ - string(credentialsId: 'TestkubeApiKey', variable: 'TESTKUBE_API_KEY'), - string(credentialsId: 'TestkubeOrgId', variable: 'TESTKUBE_ORG_ID'), - string(credentialsId: 'TestkubeEnvId', variable: 'TESTKUBE_ENV_ID') - ]) { - sh 'testkube set context --api-key $TESTKUBE_API_KEY --org $TESTKUBE_ORG_ID --env $TESTKUBE_ENV_ID' - } + // Installing and configuring Testkube based on env vars + setupTestkube() // Running Testkube test sh 'testkube run test test-name -f' @@ -152,6 +135,11 @@ you'll need to create a Jenkinsfile. This Jenkinsfile should define the stages a pipeline { agent any + environment { + TK_ORG = credentials("TK_ORG") + TK_ENV = credentials("TK_ENV") + TK_API_TOKEN = credentials("TK_API_TOKEN") + } stages { stage('Deploy to GKE') { steps { @@ -177,15 +165,8 @@ pipeline { sh 'gcloud container clusters get-credentials $GKE_CLUSTER_NAME --zone $GKE_ZONE' } - // Installing and initializing Testkube - withCredentials([ - string(credentialsId: 'TESTKUBE_API_KEY', variable: 'TESTKUBE_API_KEY'), - string(credentialsId: 'TESTKUBE_ORG_ID', variable: 'TESTKUBE_ORG_ID'), - string(credentialsId: 'TESTKUBE_ENV_ID', variable: 'TESTKUBE_ENV_ID') - ]) { - sh 'curl -sSLf https://get.testkube.io | sh' - sh 'testkube set context --api-key $TESTKUBE_API_KEY --org $TESTKUBE_ORG_ID --env $TESTKUBE_ENV_ID' - } + // Installing and configuring Testkube based on env vars + setupTestkube() // Running Testkube test sh 'testkube run test test-name -f' diff --git a/docs/sidebars.js b/docs/sidebars.js index 2409cbc7ab0..9aeab705d98 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -72,7 +72,7 @@ const sidebars = { "articles/webhooks", "articles/test-sources", "articles/test-executions", - "articles/templates", + "articles/templates", ], }, { @@ -103,6 +103,8 @@ const sidebars = { items: [ "articles/github-actions", "articles/gitlab", + "articles/jenkins", + "articles/circleci", "articles/run-tests-with-github-actions", "articles/testkube-cli-docker", { @@ -133,7 +135,7 @@ const sidebars = { "articles/generate-test-crds", "articles/logging", "articles/install-cli", - "articles/uninstall" + "articles/uninstall", ], }, { @@ -161,7 +163,7 @@ const sidebars = { "test-types/executor-tracetest", "test-types/executor-zap", "test-types/prebuilt-executor", - "test-types/container-executor", + "test-types/container-executor", "test-types/executor-distributed-jmeter", ], }, @@ -190,10 +192,7 @@ const sidebars = { { type: "category", label: "Testkube Enterprise", - items: [ - "testkube-enterprise/articles/usage-guide", - "testkube-enterprise/articles/auth" - ], + items: ["testkube-enterprise/articles/usage-guide", "testkube-enterprise/articles/auth"], }, "articles/testkube-oss", {