I'm using jenkins and selenium.
I need to send the testing url to selenium server from jenkins.
Under General Tab
Jenkins String parameter: Name = APP, Default Value = http://localhost/basecode/
Under Post-build Actions
Trigger parameterized build on other projects -> Predefined parameters -> Parameters -> SEL_APP=$APP
Above mentioned SEL_APP value needs to be written in the selenium bat file.
Suggestions are most welcome :-)
If you are using maven then you can pass the parameters through maven command.
mvn clean test -Duser=value1 -Dpass=value2
If you are building the Jenkins job with parameters then you can use jenkins parameters in maven command as
clean test -Duser=$jenkinsparam1 -Dpass=$jenkinsparam1
jenkinsparam1 - Jenkins parameter while building a job.
In the code you can use them as
String s1 = System.getProperty("user");
String s2 = System.getProperty("pass");
Use File Operations Plugin to create a bat file.
Add File Operations build step and with in it add File Create Operation. It creates the bat file with the contents provided in text area.
Use %parameter_name% in your bat file, it would directly pick it from Jenkins.
Related
Trying to set up Azure Devops pipeline for test automation run (Java + Maven + Selenium) tests are running on Browserstack
To view Browser Stack Results I added two tasks BrowserStackConfig and BrowserStackResults to pipiline YAML file
(according to instructions from BrowserStack)
But I am getting unexpected error on BrowserStackResults step : 'Build not found by name ..'
Now I am trying to get results for "old" automation run on BS (Set BROWSERSTACK_BUILD_NAME to existing BS results = 20220114_666666)
Setup:
Using Azure Devops with installed Browserstack extension
Steps:
Prepared YML file
Add pipeline for YML
Run pipeline
Result:
BS Configuration step works
Unexpected error on BrowserStackResults step "##[error] Build not found by name: "20220114_666666" error
The following only fixes BrowserStackConfig task:
variables:
- name: BROWSERSTACK_BUILD_NAME
value: "test-001"
But not for BrowserStackResults task. Is there another environment variable that controls the later? Or a list of variables used by browserstack?
According to the Browserstack
Note: Ensure to set the build capability in your test script using the environment variable BROWSERSTACK_BUILD_NAME. The extension will fail to embed test reports in your pipeline if this capability is missing.
Set variables for BrowserStack Azure DevOps Extension
The BrowserStack Azure DevOps extension, by default, sets the following environment variables:
BROWSERSTACK_USERNAME
BROWSERSTACK_ACCESS_KEY
BROWSERSTACK_LOCAL
BROWSERSTACK_LOCAL_IDENTIFIER
BROWSERSTACK_BUILD_NAME
When you create a service connection, the BROWSERSTACK_USERNAME and the BROWSERSTACK_ACCESS_KEY are automatically added as variables during the configuration step.
The extension also adds the BROWSERSTACK_BUILD_NAME variable that autogenerates a build name for your test runs.
Edit your test script to call environment variables
Edit your test script to add the environment variables for setting capabilities using the following code snippets:
String buildName = System.getenv("BROWSERSTACK_BUILD_NAME");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("build", buildName); // CI/CD job name using BROWSERSTACK_BUILD_NAME env variable
Seems you need to check your code if BROWSERSTACK_BUILD_NAME environment variable value is passed to buildName and added to capabilities. Otherwise, the report won't be generated
I am looking to pass data provider thread count value from command line an then pick this parameter in build.gradle and use it inside useTestNg() inside the test task. Is this possible?
For example:
Command: gradle clean build test -Pdataproviderthreadcount=5
Can this be captured using systemPropeties and the value to be used in useTestNg()
Since dataproviderthreadcount is a VM option, I used this as below and it worked as expected. My project is a Cucumber, Gradle and testNG.
TEST_ENV=STG BROWSER=chrome ./gradlew clean build -Dorg.gradle.jvmargs=-Ddataproviderthreadcount=2
You can also refer How can I pass VM arguments to gradle from command line?
Locally, I have successfully implemented the interface ITestEventListener within a C# netcoreapp3.1 csproj. However, when the tests are an within a Jenkins Pipeline, things appear to not be working(?).
I am using version 3.12.0 of NUnit.Engine.
By locally I am referring to using 1) Visual Studio Version 16.9.2 to run the tests and 2) command line dotnet test -c devint --test-adapter-path:. --logger:nunit to run the tests. I am getting successful test runs.
Success is my [Extension]public class ReportTestListener : ITestEventListener {...} generates an html file. I am to see the html file is created locally whereas from the Jenkins Pipeline the html file is not generated.
Within the Jenkins Pipeline, I am using the command sh "dotnet test -c ${env.TARGET_ENV} --test-adapter-path:. --logger:nunit" where env.TARGET_ENV resolves to devint. I know tests successfully run within the Jenkins Pipeline since the NUnit test results file is generated/published.
What I am not sure of is how to test/validate that the ReportTestListener is being called within the Jenkins Pipeline. I know that testing frameworks such as NUnit uses refection to identify test classes and methods. I am presuming that also happens with my implementation of [Extension]public class ReportTestListener : ITestEventListener {...}. Ideas/Suggestions on how to validate that ITestEventListener's method void OnTestEvent(string report) is being called besides writing out to disk?
Changed file writing text path to use / instead of \.
How to configure Azure function project in Intellij/Pycharm run/debug configurations on Mac because I've tried to set it by my own but it doesnt work.
I would like to replace shell command: func start with run config
The image below from Pycharm
UPDATE
I've added path to Azure-CLI and imported my app-settings
I'm trying to configure the run configs but it asks to select the module but there is no any module in dropdown (see pic)
UPDATE-UPDATE:
Here is what azure-tools-for-intellij team me answered:
They dont support pure python functions run yet
I think you shouldn't use row shell scrip with IntelliJ/PyCharm instead of this you should use Azure Toolkit for IntelliJ and run/debug your functions like in this guide.
Also when you install Azure Toolkit for IntelliJ you will have the opportunity to create run/debug configuration with predefined Azure Function ready template.
Just example:
I found the way to debug in Intellij Idea/PyCharm.
add these lines at the top of your file/module:
import pydevd_pycharm
pydevd_pycharm.settrace('127.0.0.1', port=9091, stdoutToServer=True, stderrToServer=True)
set Python Debug Server with host and port in Run/Debug Configs
run your azure functions as used to (func host start) and press debugging button.
The way I do it in PyCharm is to define a shell script configuration (Edit Configurations > Shell Script) and set:
Execute: Script set
Script text: func start
Working directory: should be to project directory where host.json etc. is located
Environment variables: leave empty
Execute in the terminal: checked
Run this configuration, which will start the test server in terminal. Then go to Run > Attach to Process... and select the process (usually it's the one without any path after the number).
My serenity project feature is working perfectly, by running maven project by using
mvn clean verify
But our leadership is against keeping login credentials(userId, password) in the feature file or any external properties file. Only supplying them in the command line like
mvn exec:java -Dexec.mainClass="com.module.test.Main" -Dexec.args="arg0 arg1 arg2"
But in Serenity, there is no Main.java file with main() method. Then
how do I invoke my serenity feature file to run using Maven with the provided 2 arguments ?
Your suggestions are highly appreciated,
First off, your company is doing the right thing. Sensitive data should never be committed to code. If it is then anybody who has access to the code has access to everything.
Serenity allows parameters to be passed at runtime, e.g.
mvn clean verify -DUSERNAME=bob -DPASSWORD=mysupersecurepassword
This will pass the values into the serenity runner. Serenity then provides a utility to read in these values using SystemEnvironmentVariables.createEnvironmentVariables, e.g.
EnvironmentVariables envs = SystemEnvironmentVariables.createEnvironmentVariables();
String username = env.getProperty("USERNAME");
String password = env.getProperty("PASSWORD");