Bitbucket Pipelines
Bitbucket Pipelines is an integrated CI/CD service built into Bitbucket. It allows you to automatically build, test, and even deploy your code based on a configuration file in your repository. Essentially, containers are created in the cloud. Inside these containers, you can run commands (similar to how you might work on a local machine) but with all the advantages of a new system configured for your needs.
The following includes information about using Provar and Bitbucket Pipelines together.
Configuring Your Provar Project
To set up Bitbucket Pipelines, you must first create and configure the bitbucket-pipelines.yml file in the root directory of your repository.
You also need to configure the Provar project and the other required files to publish it on the Bitbucket repository.
- ProvarProject: It contains the files built in Provar, such as test cases, the src folder, build.xml files, etc.
- Provar License: This includes the .license folder containing execution licenses.
Build.xml Configuration
Edit the below information in the build.xml file.
- provar.home: This value is the path of the ProvarHome folder, which contains the latest ANT libraries
- testproject.home: This value is the Provar project root in your repository
- testproject.results: The Provar results directory in your repository
- license.path: This is the path where the .license folder is located
<project default="runtests"> <property environment="env"/> <property name="provar.home" value="${env.PROVAR_HOME}"/> <property name="testproject.home" value=".."/> <property name="testproject.results" value="../ANT/Results"/> <property name="secrets.password" value="${env.PROVARSECRETSPASSWORD}"/> <property name="testenvironment.secretspassword" value="${env.ProvarSecretsPassword_EnvName}"/> <taskdef name="Provar-Compile" classname="com.provar.testrunner.ant.CompileTask" classpath="${provar.home}/ant/ant-provar.jar"/> <taskdef name="Run-Test-Case" classname="com.provar.testrunner.ant.RunnerTask" classpath="${provar.home}/ant/ant-provar.jar;${provar.home}/ant/ant-provar-bundled.jar;${provar.home}/ant/ant-provar-sf.jar"/> <taskdef name="Test-Cycle-Report" classname="com.provar.testrunner.ant.TestCycleReportTask" classpath="${provar.home}/ant/ant-provar.jar;${provar.home}/ant/ant-provar-bundled.jar;${provar.home}/ant/ant-provar-sf.jar"/> <target name="runtests"> <Provar-Compile provarHome="${provar.home}" projectPath="${testproject.home}"/> <Run-Test-Case provarHome="${provar.home}" projectPath="${testproject.home}" resultsPath="${testproject.results}" resultsPathDisposition="Increment" testEnvironment="" webBrowser="Chrome_Headless" webBrowserConfiguration="Full Screen" webBrowserProviderName="Desktop" webBrowserDeviceName="Full Screen" excludeCallableTestCases="true" salesforceMetadataCache="Reuse" projectCachePath="../../.provarCaches" testOutputlevel="WARNING" pluginOutputlevel="WARNING" stopTestRunOnError="false" secretsPassword="${secrets.password}" testEnvironmentSecretsPassword="${testenvironment.secretspassword}" invokeTestRunMonitor="true" > <fileset id="testcases" dir="../tests"></fileset> </Run-Test-Case> </target> </project>
Creating a Project in Bitbucket
Step 1: Log in to your Bitbucket account.
Step 2: Create a new repository and list the project name, repository name, and visibility level.
Step 3: Push the project configured above to the repository.
Configure your Bitbucket Pipelines
Step 1: Go to Pipelines.
Step 2: Change the template to Other. Now we need to configure the bitbucket-pipelines.yml file.
Here is an example:
image: atlassian/default-image:2 pipelines: default: - step: services: - docker script: - apt-get update && apt install wget unzip xvfb - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - - echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list - apt-get update - apt-get install google-chrome-stable -y - export PROVAR_HOME="$BITBUCKET_CLONE_DIR/ProvarHome" - mkdir $BITBUCKET_CLONE_DIR/ProvarHome - curl -O https://download.provartesting.com/latest/Provar_ANT_latest.zip - unzip -o Provar_ANT_latest.zip -d ProvarHome - rm Provar_ANT_latest.zip - cd ${BITBUCKET_CLONE_DIR}/test/ANT - xvfb-run ant -f build.xml artifacts: # defining the artifacts to be passed to each future step. - test/ANT/Results/*
Explanation of the Sample Script Above
First, we must mention the base docker image – Provar supports Java version 8, and test case execution requires ANT. So, we have taken the official photo of atlassian/default-image:2. We can also use frekele/ant:1.10.3-jdk8 image, which already has Java 8 and ant.
PROVAR_HOME is the folder’s path containing the latest Provar ANT files. This is referenced in the build.xml provar.home property.
We need to execute our UI test cases on a browser which is why the Chrome installation is included. To execute test cases in headless mode, we also need to install xvfb. Before executing the test script section, install xvfb and run the xvfb service. Execute your test cases using the xvfb-run ant -f build.xml command.
Reports and Artifacts
Step 1: To get the reports folder as artifacts in Bitbucket Pipelines, add the following in bitbucket-pipelines.yml.
artifacts: # defining the artifacts to be passed to each future step. - test/ANT/Results/*
Step 2: Now, commit the file. This will create a file named bitbucket-pipelines.yml in your Bitbucket repository.
Step 3: Go to Pipelines. You can see your pipeline running.
Step 4: Click on the Artifacts Tabs. You can download the artifacts here.
Parameterization using Environment Variables
Parameterizations can be used to execute the following:
- Using the secrets and environments password
- Adding data to the build.xml file at run time
To add variables to the repository, follow the below steps:
Step 1: Click the Repository Settings.
Step 2: Add a variable for the secret password. Mark it as secure, which will mask the value.
Step 3: Add a variable for the browser as well. This will help you to define the browser where the execution will be performed.
You can access the variables using the ${env.VARIABLENAME} format in the build.xml file, as shown in the screenshot below.
Parallel Testing
You can achieve parallel testing by configuring parallel steps in Bitbucket Pipelines. Add a set of steps in your bitbucket-pipelines.yml file in the parallel block. These steps will be initiated in parallel by Bitbucket Pipelines so they can run independently and complete faster.
Here is an example:
image: "frekele/ant:1.10.3-jdk8" pipelines: default: - step: name: No parallel tag services: - docker script: - echo "Without parallel Tag" - parallel: - step: name: Parallel 1 services: - docker script: - apt-get update && apt install wget unzip xvfb - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - - echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list - apt-get update - apt-get install google-chrome-stable -y - cd test/ANT && xvfb-run ant -f build.xml artifacts: # defining the artifacts to be passed to each future step. - test/ANT/Results/* - step: name: Parallel 2 services: - docker script: - apt-get update && apt install wget unzip xvfb - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - - echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list - apt-get update - apt-get install google-chrome-stable -y - cd test/ANT && xvfb-run ant -f build.xml artifacts: # defining the artifacts to be passed to each future step. - test/ANT/Results/*
Job Scheduling
You can schedule your jobs in Bitbucket Pipelines.
Step 1: Go to Pipelines.
Step 2: Click on Schedules.
Step 3: Select your branch, pipeline, and schedule (i.e., Hourly, Weekly, or Daily). This will schedule your run as per the configuration.
Executing BitBucket Pipelines using a REST API
You can use webhooks if you would like to execute the pipeline from any external application or release management tool like Copado, Flosum, etc. For more information about incoming webhook requests, please refer to the following:
- General information
- Licensing Provar
- Provar trial guide and extensions
- Using Provar
- API testing
- Behavior-driven development
- Creating and importing projects
- Creating test cases
- Custom table mapping
- Functions
- Debugging tests
- Defining a namespace prefix on a connection
- Defining proxy settings
- Environment management
- Exporting test cases into a PDF
- Exporting test projects
- Override auto-retry for Test Step
- Managing test steps
- Namespace org testing
- Provar desktop
- Provar Test Builder
- Refresh and Recompile
- Reload Org Cache
- Reporting
- Running tests
- Searching Provar with find usages
- Secrets management and encryption
- Setup and teardown test cases
- Tags and Service Level Agreements (SLAs)
- Test cycles
- Test plans
- Testing browser options
- Tooltip testing
- Using the Test Palette
- Using custom APIs
- Callable tests
- Data-driven testing
- Page objects
- Block locator strategies
- Introduction to XPaths
- Creating an XPath
- JavaScript locator support
- Label locator strategies
- Maintaining page objects
- Mapping non-Salesforce fields
- Page object operations
- ProvarX™
- Refresh and reselect field locators in Test Builder
- Using Java method annotations for custom objects
- Applications testing
- DevOps
- Introduction to test scheduling
- Apache Ant
- Configuration for Sending Emails via the Provar Command Line Interface
- Continuous integration
- AutoRABIT Salesforce DevOps in Provar Test
- Azure DevOps
- Running a Provar CI Task in Azure DevOps Pipelines
- Configuring the Provar secrets password in Microsoft Azure Pipelines
- Parallel Execution in Microsoft Azure Pipelines Using Multiple build.xml Files
- Parallel Execution in Microsoft Azure Pipelines using Targets
- Parallel execution in Microsoft Azure Pipelines using Test Plans
- Bitbucket Pipelines
- CircleCI
- Copado
- Docker
- Flosum
- Gearset DevOps CI/CD
- GitHub Actions
- Integrating GitHub Actions CI to Run Provar CI Task
- Remote Trigger in GitHub Actions
- Parameterization using Environment Variables in GitHub Actions
- Parallel Execution in GitHub Actions using Multiple build.xml Files
- Parallel Execution in GitHub Actions using Targets
- Parallel Execution in GitHub Actions using Test Plan
- Parallel Execution in GitHub Actions using Job Matrix
- GitLab Continuous Integration
- Travis CI
- Jenkins
- Execution Environment Security Configuration
- Provar Jenkins Plugin
- Parallel Execution
- Running Provar on Linux
- Reporting
- Salesforce DX
- Git
- Team foundation server
- Version control
- Salesforce testing
- Adding a Salesforce connection
- Assert Page Error Messages on Add/Edit Product
- Dynamic Forms
- Internationalization support
- List and table testing
- Salesforce Release Updates
- Salesforce Lightning Testing
- Salesforce Lightning Web Component (LWC) locator support
- Salesforce console testing
- Visualforce Testing
- Performance Best Practices
- Testing best practices
- Troubleshooting
- Browsers
- Configurations and permissions
- Connections
- DevOps
- Error messages
- Administrator has blocked access to client
- JavascriptException: Javascript error
- macOS Big Sur Upgrade
- Resolving failed to create ChromeDriver error
- Resolving Jenkins license missing error
- Resolving metadata timeout errors
- Test execution fails – Firefox not installed
- Update to Opportunity field validation behaviour
- Licensing, installation and firewalls
- Memory
- Test Builder and test cases
- Release notes