Forum Discussion

Yki's avatar
Yki
Contributor
2 years ago

Using readyApi with Github Actions and Maven

I am the only one who is trying to do this? If not please. HELP  How / Where do I set the accesstoken.   Why is there no solution to run ReadyAPI with Maven on a headless machine with this "§$&$§" ...
  • Yki's avatar
    2 years ago

     thank you nmrao  I opened several tickets for various problems I am facing. Instead of answering they released a new version and with chatgpt I was able to solve my issues for now...

     

    KonGres 

    This is how it working for me
    1. POM

     

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    	<groupId>groupId</groupId>
    	<artifactId>flexibill-soapui-tests</artifactId>
    	<version>1.0</version>
    	<packaging>pom</packaging>
    	<name>ReadyApi Project Name</name>
    	<organization>
    		<name>company</name>
    		<url>https://www.google.com</url>
    	</organization>
    	<properties>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    	</properties>
    	<repositories>
        </repositories>
    	<pluginRepositories>
    		<pluginRepository>
    			<id>SmartBearPluginRepository</id>
    			<url>https://smartbearsoftware.com/repository/maven2</url>
    		</pluginRepository>
    		<pluginRepository>
    			<id>com.teamdev</id>
    			<url>https://europe-maven.pkg.dev/jxbrowser/releases</url>
    		</pluginRepository>
    	</pluginRepositories>
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>com.smartbear</groupId>
    				<artifactId>ready-api-maven-plugin</artifactId>
    				<version>3.46.0</version>
    				<configuration>
    					<!--<globalProperties> <value>preemptive=true</value> </globalProperties> -->
    					<slmAccessKey>your-access-key</slmAccessKey>
    					<projectFile>project_folder</projectFile>
    					<printReport>false</printReport>
    					<outputFolder>${project.build.directory}/readyapi</outputFolder>
    					<junitReport>true</junitReport>
    					<exportAll>true</exportAll>
    					<readyApiProperties>
    						<property>
    							<name>readyapi.logroot</name>
    							<value>${project.build.directory}/readyapi-logs/</value>
    						</property>
    						<property>
    							<name>licenseApiAccessForEveryone</name>
    							<value>true</value>
    						</property>
    					</readyApiProperties>
    					<environment>${env}</environment>
    					<testSuite>${testSuite}</testSuite>
    					<testCase>${testCase}</testCase>
    					<tags>
    						<param>TestCase ${env}</param>
    					</tags>
    					<!-- Only test cases with corresponding tags will be executed -->
    				</configuration>
    				<dependencies>
    					<dependency>
    						<groupId>mysql</groupId>
    						<artifactId>mysql-connector-java</artifactId>
    						<version>8.0.28</version>
    					</dependency>
    					<dependency>
    						<groupId>org.iban4j</groupId>
    						<artifactId>iban4j</artifactId>
    						<version>3.2.1</version>
    					</dependency>
    					<dependency>
    						<groupId>com.smartbear</groupId>
    						<artifactId>ready-api-jdbc-virts</artifactId>
    						<version>3.3.2</version>
    					</dependency>
    				</dependencies>
    				<executions>
    					<execution>
    						<phase>test</phase>
    						<goals>
    							<goal>test</goal>
    						</goals>
    					</execution>
    				</executions>
    			</plugin>
    		</plugins>
    	</build>
    </project>

     

     

     2. yaml for Github actions

     

    name: manual_create_testdata
    concurrency: build
    
    on:
      workflow_dispatch:
        inputs:
          environment:
            description: Please specify environment (Integration/Test) for manual run
            required: true
            type: choice
            options:
              - Integration
              - Test
          testsuite:
            description: Please specify testsuite for a specific manual run
            required: false
            type: string
          testcase:
            description: Please specify testcase for a specific manual run e.g.getTodaysDates
            required: false
            type: string
      # schedule:
        # Runs "runs at 5 am every day" (see https://crontab.guru)
        # - cron: '0 5 * * *'
    
    
    jobs:
      build:
    
        runs-on: ubuntu-latest
    
        steps:
    
        - name: Checkout branch
          uses: actions/checkout@v3
    
        - name: Setup Maven Action
          uses: s4u/setup-maven-action@v1.2.1
          with:
            java-version: 17.0
            maven-version: 3.9.0
    
        - name: Install Smartbear
          run: |
            echo "Installing Smartbear API"  
    
            sudo apt-get update -y && sudo apt-get install -y lsb-release software-properties-common && sudo apt-get clean all
            sudo apt-get install wget curl gnupg apt-utils fontconfig jq -y 
            curl https://dl.eviware.com/ready-api/3.46.0/ReadyAPI-x64-3.46.0.sh -o ReadyAPI-x64-3.46.0.sh
            sudo chmod +x ./ReadyAPI-x64-3.46.0.sh
            
    
        - name: Build with Maven
          run: |
            echo "Running Maven build on ${{ github.event.inputs.environment }}"
    
            # Check if both 'testcase' and 'testsuite' are defined
            if [[ -n "${{ github.event.inputs.testcase }}" && -n "${{ github.event.inputs.testsuite }}" ]]; then
              echo "Executing Maven command with testcase and testsuite"
              mvn clean test -Denv="${{ github.event.inputs.environment }}" -DtestSuite="${{ github.event.inputs.testsuite }}" -DtestCase="${{ github.event.inputs.testcase }}" -U --file pomGIT.xml
            elif [[ -n "${{ github.event.inputs.testsuite }}" ]]; then
              # If only 'testsuite' is defined
              echo "Executing Maven command with testsuite"
              mvn clean test -Denv="${{ github.event.inputs.environment }}" -DtestSuite="${{ github.event.inputs.testsuite }}" -U --file pomGIT.xml
            elif [[ -n "${{ github.event.inputs.testcase }}" ]]; then
              # If only 'testcase' is defined
              echo "Executing Maven command with testcase"
             mvn clean test -Denv="${{ github.event.inputs.environment }}" -DtestCase="${{ github.event.inputs.testcase }}" -U --file pomGIT.xml
            else
             # If neither 'testsuite' nor 'testcase' is defined
             echo "Executing Maven command without testsuite and testcase"
              mvn clean test -Denv="${{ github.event.inputs.environment }}" -U --file pomGIT.xml
            fi