diff --git a/website/docs/using_rf_in_ci_systems/ci/jenkins.md b/website/docs/using_rf_in_ci_systems/ci/jenkins.md index 8237e4b2..567d3cad 100644 --- a/website/docs/using_rf_in_ci_systems/ci/jenkins.md +++ b/website/docs/using_rf_in_ci_systems/ci/jenkins.md @@ -4,7 +4,7 @@ Jenkins is an open source automation server, which allows you to integrate into multiple different tools and platforms with various plugins. In order to run **jobs**, you need a **Jenkinsfile** written in Groovy. Each Jenkinsfile has some -**stages**, which contain one or more **steps**. Each job is run one some **node** +**stages**, which contain one or more **steps**. Each job is run on some **node** (or **agent**), which contains all the necessary software to run your job. If you want to run Robot Framework in your Jenkins job, you need to have `robotframework` installed @@ -38,15 +38,13 @@ pipeline { post { always { - // `onlyCritical: false` is for RF 3.x compatibility. This will be deprecated - // and removed in the future. - robot outputPath: '.', passThreshold: 80.0, unstableThreshold: 70.0, onlyCritical: false + robot outputPath: '.', passThreshold: 80.0, unstableThreshold: 70.0 } } } ``` -### Jenkinsfile with parameters and multiple stages +### Jenkinsfile with parameters and multiple stages ```groovy pipeline { @@ -57,6 +55,7 @@ pipeline { string(name: 'EXCLUDE', description: 'Specify if you want to exclude tests by category tags'), string(name: 'FOLDER', defaultValue: 'tests', description: 'Specify the folder for tests (e.g. . for current dir'), string(name: 'BRANCH', defaultValue: 'main', description: 'Specify the branch for tests (e.g. main') + ]) ]) // -- Script arguments -------------------------------- @@ -67,7 +66,7 @@ pipeline { def args = "" // ---------------------------------------------------- - agent { label 'robot'} // how is your Jenkins agent labeled, so that right kind of agent is used for execution + agent { label 'robot' } // how is your Jenkins agent labeled, so that right kind of agent is used for execution stages { stage('Checkout') { @@ -97,24 +96,30 @@ pipeline { stage('Run Robot tests') { steps { sh """ - // command to run your tests + robot -d test_results ${args} # etc. """ } post { always { - step([ - $class : 'RobotPublisher', - outputPath : 'test_results', - outputFileName : "output.xml", - reportFileName : 'report.html', - logFileName : 'log.html', - disableArchiveOutput: false, - passThreshold : 95.0, - unstableThreshold : 95.0, - otherFiles : "**/*.png", - ]) + // Note! Careful not to mix the Jenkins `robot` step with the `robot` command run inside the previous + // `sh` step! The `robot` step _only_ publishes the results for Jenkins and the `robot` command + // inside `sh` step runs the tests! + robot( + outputPath : 'test_results', + outputFileName : "output.xml", + reportFileName : 'report.html', + logFileName : 'log.html', + disableArchiveOutput: false, + passThreshold : 95.0, + unstableThreshold : 95.0, + otherFiles : "**/*.png", + ) } } + } + // Other stages... + } +} ``` ## Special notes about running tests with Browser library behind firewall @@ -124,16 +129,18 @@ This is related especially to the use of Browser library which requires installa ### Preparing the Jenkins agent These are steps that needs to be done by the person administrating the Jenkins agents. + 1. Install all the tools that are needed for running the tests: nodejs, python 3.x, Robot Framework, Browser library -1. Set ```PLAYWRIGHT_BROWSERS_PATH``` to point where you want to install browsers -1. Execute ```rfbrowser init``` to get the base setup for Browser library. Note that you still need to execute it with Jenkins user as well, see below. +1. Set `PLAYWRIGHT_BROWSERS_PATH` to point where you want to install browsers +1. Execute `rfbrowser init` to get the base setup for Browser library. Note that you still need to execute it with Jenkins user as well, see below. ### Preparing the Jenkins configuration file These are steps you need to have in your Jenkins configuration. I recommend putting those as commands in the same shell command set together with test execution ("command to run your tests") -1. ```npm config set registry https://local-site-for-node-modules``` \<-- here you need a server that is providing all required node modules; if it doesn't exist proxy config might work as well -1. Additional commands that might be needed could be ```npm config set strict-ssl false``` or ```npm config set always-auth true```depending how the server is configured -1. Then run ```rfbrowser init --skip-browsers``` to avoid the installation of browsers that may appear hard over the firewall -1. ... and use instead the ones installed by root when the agent was initialised by pointing with ```PLAYWRIGHT_BROWSERS_PATH``` to the location defined + +1. `npm config set registry https://local-site-for-node-modules` \<-- here you need a server that is providing all required node modules; if it doesn't exist proxy config might work as well +1. Additional commands that might be needed could be `npm config set strict-ssl false` or `npm config set always-auth true` depending how the server is configured +1. Then run `rfbrowser init --skip-browsers` to avoid the installation of browsers that may appear hard over the firewall +1. ... and use instead the ones installed by root when the agent was initialised by pointing with `PLAYWRIGHT_BROWSERS_PATH` to the location defined Now you should be ready to execute tests.