Posts

Property Reader In Java

Sample Property Reader in Java public class PropertyReader { private static Properties properties = new Properties(); static { try { ClassLoader classLoader = Thread. currentThread ().getContextClassLoader(); InputStream inputStream = classLoader.getResourceAsStream( "filename.properties" ); properties = new Properties(); properties .load(inputStream); inputStream.close(); } catch (Exception ex) { ex.printStackTrace(); } } public static boolean containsKey(String key) { if ( properties .containsKey(key)) { return true ; } return false ; } public static String getPropertyValue(String key) { if ( properties .containsKey(key)) { return (String) properties .get(key); } return null ; } public static void setPropertyValue(String key, String value) { ...

Jenkins Declarative Pipeline

Image
Sample Jenkins Declarative Pipeline def A = false def B = true pipeline { agent any tools { maven 'MVN' jdk 'JDK' } stages { stage('Build Stage') { steps { git "https://github.com/nishantautomationlabs/nal-junitmockito.git" sh "mvn -U clean compile install -DskipTests" echo 'Build Stage executed' } } stage('Unit Test Stage') { steps { sh "mvn -Dtest=MockitoExampleTest test" echo 'Unit Test Stage executed' } } stage('Master Stage'){ when{ branch 'master' } steps { echo 'run this stage only if its running on the master branch' } } stage('Conditional Stage') { when { ...

Jenkins Scripted Pipeline

Image
Sample Jenkins Scripted Pipeline node { stage "Git Pull" git "https://github.com/nishantautomationlabs/nal-junitmockito.git" echo "code pulled" stage "Run Declarative Pipeline" build "Declarative Pipeline" echo "Declarative Pipeline triggered" stage "print" for(int i = 0; i < 10; i++) { if(i % 2 == 0) { echo "Number " + i } } } Jenkins Configuration: Build History:

Hot to fix apt-get “The following signatures were invalid: KEYEXPIRED”

Image
Hot to fix apt-get “The following signatures were invalid:  KEYEXPIRED ” If you are trying to run  apt-get update on your ubuntu machine and seeing the error "The following signatures were invalid: KEYEXPIRED" you have come to the right place. The key expired error occurs when one or more existing key on your ubuntu machine has expired which is hindering the update. To fix this issue, you need to renew these keys. Here are the steps to renew an expired key Find the expired Key:  Run the below command which will list all the expired keys on your ubuntu machine. Make a note of all the keys.  sudo apt-key list | grep -A 1 expired Renew the expired Key:  Take the keys from the previous command output and replace the <KEY_ID> in te below command with that. Execute this command to renew the expired key. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys <KEY_ID> Run apt-get update:  Now that you have renewed all the...

Install Docker on Ubuntu 16.04

Install Docker on Ubuntu 16.04 Docker Engine is an open-source containerization technology for building and containerizing your applications. Docker Engine acts as a client-server application with: A server with a long-running daemon process dockerd . APIs which specify interfaces that programs can use to talk to and instruct the Docker daemon. A command-line interface (CLI) client docker. To install Docker on your Ubuntu 16.04 machine, follow the following steps. Install Dependent packages:   Update the package index and install packages to allow apt to use a repository over HTTPS. sudo apt-get update   sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common Add repository key:    Add repository key to the package manager curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - Verify fingerprint:    Verify that you now have the key with the fingerprint sudo apt-...

Selenium Grid using Zalenium

Image
Selenium Grid using Zalenium Zalenium is a flexible and scalable container based Selenium Grid with video recording, live preview, basic auth & dashboard. To setup Zalenium, follow the following steps. Prerequisite:  Docker is pre-installed. Pull Docker Images:  Pull the elgalu selenium and zalenium docker images. docker pull elgalu/selenium   docker pull dosel/zalenium Run Zalenium:  Start zalenium using the command docker run --rm -ti --name zalenium -p 4444:4444  -v /var/run/docker.sock:/var/run/docker.sock  -v /tmp/videos:/home/nishant/videos --privileged dosel/zalenium start Stop Zalenium:  To stop zalenium run the command docker stop zalenium Access Selenium Hub:  Access the selenium hub   at   http://localhost:4444/grid/console   Access Selenium Grid Live View:  Access the selenium grid live view at   http://localhost:4444/grid/admin/live   Access Zalenium Dashbo...

Setup WordPress with MySQL using Docker Compose

Setup WordPress with MySQL using  Docker Compose Prerequisite:  Docker and docker-compose are installed. Create YAML File:  To create a docker-compose YAML file for Wordpress, create a new YAML file with the below content. wordpress-mysql .yaml version: '3.3' services:    db:      image: mysql:5.7      volumes:        - db_data:/var/lib/mysql      restart: always      environment:        MYSQL_ROOT_PASSWORD: test123!        MYSQL_DATABASE: nishantmysql        MYSQL_USER: nishant        MYSQL_PASSWORD: test123!    wordpress:      depends_on:        - db      image: wordpress:latest      ports:        - "8000:80"      restart: always      environment...