Forum Discussion

Kilimanjaro91's avatar
Kilimanjaro91
New Contributor
3 years ago

Zephyr scale Jira & Circleci integration

Hi all,

I'm trying to update test results executed from CircleCi build to Jira test cycle but don't know how to config. Please help!

This is my CircleCi config.yml

version: 2.1

jobs:
  build-and-test:
    docker:
      - image: cimg/openjdk:11.0
        environment:
          dev: https://dev.myapp.com
          qa: https://qa.myapp.com
    steps:
      - checkout
      - run:
          name: Build and clean
          command: mvn -B -DskipTests clean package
      - run:
          name: run tests
          command: mvn test
      - run:
          name: Save test results
          command: |
            mkdir -p ~/test-results/cucumber/
            find . -type d -name "*cucumber-html-reports*" -exec cp -r {} ~/test-results/cucumber/ \;
          when: always
      - store_test_results:
          path: ~/test-results
      - store_artifacts:
          path: ~/test-results/cucumber
      - run:
          name: Zephyr integration
          command: |
            zip output_results.zip ~/test-results/cucumber/*
            curl --basic --user my_jira_email:my_jira_password -F "file=@output_results.zip"
            https://mycompany.atlassian.net/rest/atm/1.0/automation/execution/cucumber/FL?autoCreateTestCases=false

workflows:
  sample:
    jobs:
      - build-and-test

This is my test runner (Karate framework + cucumber)

package JSONapi.features;

import com.intuit.karate.junit5.Karate;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import org.apache.commons.io.FileUtils;
import static org.junit.Assert.*;
import org.junit.BeforeClass;
import org.junit.Test;
public class TestRunnerParallel {
    @BeforeClass
    public static void beforeClass(){
        System.setProperty("karate.env","local");
    }
    test
    public void testParallel() {
        Results results = Runner.path("classpath:JSONapi")
                .outputCucumberJson(true)
                .tags("~@ignore")
                .parallel(5);
        generateReport(results.getReportDir());
        System.out.println("Report directory: "+results.getReportDir());
        assertTrue(results.getErrorMessages(), results.getFailCount() == 0);
    }
    public static void generateReport(String karateOutputPath) {
        Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
        List<String> jsonPaths = new ArrayList<>(jsonFiles.size());
        jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
        Configuration config = new Configuration(new File("target"), "JSONapi");
        ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
        reportBuilder.generateReports();
    }
}

My cucumber feature file

My Test cycle and test case info

Error in circleCi job

 

4 Replies

  • Can you try

    curl -X POST https://mycompany.atlassian.net/rest/api/1.0/automation/execution/cucumber/FL?autoCreateTestCases=false \           
    --basic --user my_jira_email:my_jira_password -F "file=@output_results.zip"
    • Kilimanjaro91's avatar
      Kilimanjaro91
      New Contributor

      Hi DavidL 

       

      It said using jira username & password is depreciated, is it possible to use Zephyr scale access token as follows?

       

       

      curl -X POST https://api.zephyrscale.smartbear.com/v2/automations/executions/cucumber?projectKey=FL&autoCreateTestCases=false -H "Authorization: Bearer my_token_string" -H "Content-type: multipart/form-data" -F "file=@cucumber-html-reports.zip"

       However, there is an error in the CI/CD build when I tried the new command line.

       

       

       

      • Kilimanjaro91's avatar
        Kilimanjaro91
        New Contributor
         - run:
                  name: Zephyr integration
                  command: |
                    zip -r test-results.zip ~/test-results
                    curl -X POST --location --request POST 'https://api.zephyrscale.smartbear.com/v2/automations/executions/cucumber?projectKey=FL&autoCreateTestCases=false' \
                    --header 'Authorization: Bearer my_token' \
                    --form 'file=@"test-results.zip"' \
                    --form 'testCycle="{\"name\":\"my_test_cycle_name\",\"folderId\":my_folder_id}";type=application/json'
                  when: always

        I updated the tests successfully. However this will create a new test cycle whenever the build runs