Bitbucket Pipeline custom variable is not showing its value in step script - selenium

I have created a pipeline for running automation script from bitbucket, when I trigger build with docker container all custom variable is working (it pass the correct values) but when I run the same project in self.hosted machine and pass the variables it show blank values.
Below is the sample of pipeline file
# This is an example Starter pipeline configuration
# Use a skeleton to build, test and deploy using manual and parallel steps
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: atlassian/default-image:2
pipelines:
pull-requests: #Trigger pipeline project on each Pull-Request
'**':
- step:
name: 'version check'
image: maven:3.3.9
caches:
- maven
script:
- echo "Your versions here..."
- mvn --version
- step:
name: 'Clean and Build'
script:
- mvn -f TestAutomation/pom.xml clean compile
custom:
Automation-Run: #Name of this pipeline
- variables:
- name: testngFile
default: "src/test/resources/testng"
- name: browser
default: "CHROME"
allowed-values: # optionally restrict variable values
- "CHROME"
- "FIREFOX"
- name: environment
default: STAGING
allowed-values:
- "STAGING"
- "QA"
- "PROD"
- name: forkCount
default: "0"
- name: tags
default: Regression
- step:
name: 'Connect to Runner & Automation-Run'
runs-on:
- self.hosted
- windows
- testautomation
script:
- cd TestAutomation
- .\Example1.bat ${testngFile} ${browser} ${environment} ${tags}
artifacts:
- /target/surefire-reports/**.xml
inside Example1.bat file I have mentioned below command
mvn clean test -Dproject.testngFile=%1 -Dbrowser.name=%2 -Dproject.environment=%3 -Dcucumber.filter.tags=#%4
enter image description here
enter image description here
I am expecting when user enter any values, it picked and stored into variable and those variables are pass to Example1.bat as runtime command line args.

Related

I'm able to access gitlab runner when I run .gitlab-ci.yml , but unable to find the directory in the runner(ec2 instance)

stages:
- deploy
deploy_ssh:
stage: deploy
image:
name: registry.gitlab.com/torese/docker-ansible
variables:
ANSIBLE_HOST_KEY_CHECKING: 'false'
ANSIBLE_FORCE_COLOR: 'true'
ANSIBLE_PYTHON_INTERPRRTER: /usr/bin/python3
GIT_CLEAN_FLAGS: none
before_script:
- export AWS_ACCESS_KEY_ID=$TEST_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$TEST_AWS_SECRET_ACCESS_KEY
- export AWS_DEFAULT_REGION=$TEST_AWS_DEFAULT_REGION
script:
- mkdir ./subba
- touch ./subba/demo
- echo "Hello world" >> ./subba/demo
tags:
- devaws # my gitlabrunner tag
see the above info while run pipeline job succeeded but when i goto runner instance I'm unable to find the ./subba directory ?
can anyone help me with this
thanks

Trigger GitLab pipeline based on an external event (Example - A binary image has been uploaded to Nexus)

I have a problem where the application code is developed and built in vendor premises and only code binary is sent in the form of docker image and uploaded to Nexus repository. Now, I need to create a deployment pipeline in GitLab which will be triggered as soon as a new image is uploaded to nexus.
Please suggest any solution.
I have tried to create a parent child pipeline where I am trying to check the HTTP resonse status from Nexus through curl request, trigger the child pipeline only when the status is 200. The parent pipeline can be configured as a scheduled pipeline which will check the image availability on a regular interval.
Parent yml:
stages:
- build
- trigger_child
build:
stage: build
script:
- echo "img_status=`curl -s -o /dev/null -w "%{http_code}" https://www.google.com`" >> build.env
artifacts:
reports:
dotenv: build.env
trigger_child:
stage: trigger_child
trigger:
include:
- local: App/.gitlab-ci.yml
strategy: depend
needs:
- job: build
artifacts: true
rules:
- if: $img_status == "200"
when: always
Child yml:
stages:
- deploy
deploy:
stage: deploy
script:
- echo "This job deploys something new"

Selenium-JAVA maven project CI/CD pipeline using CircleCI

I tried to create CI/CD pipeline for Selenium maven project using CircleCI. but I found webDriverException. Here, I attached screenshot and circleCI.yml file. enter image description here
enter image description hereenter image description here
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/openjdk:11-jdk
working_directory: ~/demoProject
environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: mvn dependency:go-offline
- run:
name: Running X virtual framebuffer
command: Xvfb :0 -ac &
- run:
name: Run Tests
command: |
export DISPLAY=:99
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
# run tests!
- run: mvn clean test
- store_artifacts:
path: target/surefire-reports
destination: tr1
- store_test_results:
path: target/surefire-reports

Gitlab CI Include is not including

I don't get it. I have two repos. One for infrastructure, and the other for project code. Inside project code, I have .gitlab-ci.yml file that will include one job for creating env variables, another include file that will include other stages inside the job. Every other stage is triggered, but the first include is not triggered no matter what I do. What am I doing wrong?
Project gitlab-ci
# Stages
stages:
- pre-build test
- build
- post-build test
- deploy
- environment
- e2e
# Main Variables
variables:
GIT_SUBMODULE_STRATEGY: normal
IMAGE_VERSION: "latest"
CARGO_HOME: $CI_PROJECT_DIR/.cargo
FF_USE_FASTZIP: "true"
ARTIFACT_COMPRESSION_LEVEL: "fast"
CACHE_COMPRESSION_LEVEL: "fastest"
STAGING_BRANCH: "master"
VARIABLES_FILE: variables.txt
# Include main CI files from infrastructure repository
include:
- project: 'project/repo-one'
ref: master
file: '/gitlab-ci/env/ci-app-env.yml'
- project: 'project/repo-one'
ref: master
file: '/gitlab-ci/app/ci-merge-request.yml'
env ci file
env mr:
stage: .pre
before_script:
- TEST_VAR="TEST"
- IMAGE_PATH="/var/www"
script:
- echo "export TEST_VAR=$TEST_VAR" > $VARIABLES_FILE
- echo "export IMAGE_PATH=$IMAGE_PATH" > $VARIABLES_FILE
- cat $VARIABLES_FILE
artifacts:
paths:
- $VARIABLES_FILE

Bitbucket pipeline not running Chromedriver executable

So I'm running in to an error where I have a simple front end login test to a website using selenium. When I run the test in the bitbucket pipelines I'm running in to this error
java.lang.IllegalStateException: The driver executable does not exist: /opt/atlassian/pipelines/agent/build\chromedriver.exe
Bitbucket yml file
image: gradle:6.6.0
pipelines:
default:
- parallel:
- step:
name: Build and Test
caches:
- gradle
script:
- gradle build
after-script:
- pipe: atlassian/checkstyle-report:0.2.0
- step:
name: Security Scan
script:
# Run a security scan for sensitive data.
# See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security
- pipe: atlassian/git-secrets-scan:0.4.3
Does anyone know what the issue may be ?
I see 2 things:
You are specifying the driver file so the route could be incorrect.
java.lang.IllegalStateException: The driver executable does not exist: /opt/atlassian/pipelines/agent/build\chromedriver.exe
You are using a gradle image
image: gradle:6.6.0
but I don't think that you have a driver/browser in that image.
You will need to add another image with a browser, like this https://hub.docker.com/r/selenium/standalone-chrome, you can find more examples here https://github.com/SeleniumHQ/docker-selenium and add it to your file. Something like this:
image: gradle:6.6.0
pipelines:
default:
- parallel:
- step:
name: Build and Test
caches:
- gradle
services:
- chrome
script:
- gradle build
after-script:
- pipe: atlassian/checkstyle-report:0.2.0
- step:
name: Security Scan
script:
# Run a security scan for sensitive data.
# See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security
- pipe: atlassian/git-secrets-scan:0.4.3
definitions:
services:
chrome:
image: selenium/standalone-chrome
You will need to change your code to use a RemoteWebDriver
https://www.selenium.dev/documentation/en/remote_webdriver/remote_webdriver_client/