I know this question is pretty old. I found some answers for hosting allure using a third party and amazon aws s3 bucket. The first one is not good from a security standpoint and the second one involves money. So let's look at the below one which is free. Hope this helps people who are struggling with the same issue.
The below steps are detailed and it works a hundred percent.
- Download the allure command-line zip file from the maven central. 2.13.5 is
the latest version when I am writing this. Zip file can be downloaded
from the below link. The below link is not spam or malware. If you want, you can go this link manually from your browser as well :)
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.13.5/allure-commandline-2.13.5.zip
- Next step is extract this folder and move it to your testng repo code base. In my case I have kept the extracted folder under src/main/resources/config
- Each time you generate a allure-report from the java code, copy this allure-2.13.5 folder inside the report folder generated.
- Then you need to have two files to open the report in any machine(even in a machine which doesn't have allure installed). If you are using mac, then that file is a shell script open_report_mac.sh. If you are using windows, then that file is a batch script open_report_windows.bat.
- Now you can share the entire allure-report folder to anyone, they just need to run this batch file or shell script to view the report. I know this is a long method, but this works on machines even without allure.
Code for open_report_windows.bat:
SET PARENTDIR=%cd%
cd %PARENTDIR%allure-2.13.5in
allure.bat open %PARENTDIR%
Code for open_report_mac.sh:
parent_dir=$(pwd)
cd $parent_dir/allure-2.13.5/bin
allure open $parent_dir
For those who doesn't know how to generate allure-repor programmatically below is my code. Important Note: You need to have allure installed on your mac for the below code to work.
public static void generateAllureReport() {
String pattern = "dd-MM-yyyy_HH:mm:ss";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
String reportfolder = "allure-report_" + simpleDateFormat.format(new Date());
executeShellCmd("allure generate allure-results");
executeShellCmd("mv allure-report " + reportfolder);
executeShellCmd("cp -R src/main/resources/config/allure-2.13.5 "+reportfolder);
executeShellCmd("cp src/main/resources/config/open_report_mac.sh "+reportfolder);
executeShellCmd("cp src/main/resources/config/open_report_windows.bat "+reportfolder);
}
public static void executeShellCmd(String shellCmd) {
try {
Process process = Runtime.getRuntime().exec(shellCmd);
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error in Executing the command " + shellCmd);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…