
gitlab-ci.yml a "step" must be included in the maven_build section, that will use "curl" in order to submit the results to the REST API. The user present in the configuration below must exist in the JIRA instance and have permission to Create Test and Test Execution Issues Therefore, we'll use some secret variables defined in GitLab project settings. However, we do not want to have the JIRA credentials hardcoded in GitLab's configuration file. In order to submit those results, we'll just need to invoke the REST API (as detailed in Import Execution Results - REST). 'curl -H "Content-Type: multipart/form-data" -u $jira_user:$jira_password -F "$jira_server_url/rest/raven/1.0/import/execution/junit?projectKey=CALC"'

# To keep cache across branches add 'key: "$CI_JOB_REF_NAME"' # Cache downloaded dependencies and plugins between builds. MAVEN_CLI_OPTS: "-batch-mode -errors -fail-at-end -show-version -DinstallAtEnd=true -DdeployAtEnd=true" # `installAtEnd` and `deployAtEnd`are only effective with recent version of the corresponding plugins. # As of Maven 3.3.0 instead of this you may define these options in `.mvn/nfig` so the same config is used MAVEN_OPTS: "=.m2/repository .transfer.Slf4jMavenTransferListener=WARN =true =true" You need to specify `-batch-mode` to make this work. # `showDateTime` will show the passed time in milliseconds. # This will supress any download for dependencies and plugins or upload messages which would clutter the console log. gitlab-ci.yml contains the definition of the build steps, including running the automated tests and submitting the results.

Public class CalcTest void setUp() throws Exception void tearDown() throws Exception void CanAddNumbers()ĪssertThat(Calculator.Add(-1, 1), void CanSubtract()ĪssertThat(Calculator.Subtract(1, 1), is(0)) ĪssertThat(Calculator.Subtract(-1, -1), is(0)) ĪssertThat(Calculator.Subtract(100, 5), void CanMultiply()ĪssertThat(Calculator.Multiply(1, 1), is(1)) ĪssertThat(Calculator.Multiply(-1, -1), is(1)) ĪssertThat(Calculator.Multiply(100, 5), is(500)) ĪssertThat(Calculator.Divide(1, 1), is(1)) ĪssertThat(Calculator.Divide(-1, -1), is(1)) ĪssertThat(Calculator.Divide(100, 5), void CanDoStuff()
