0

In gitlab in CI/CD in Schedules I am creating a new schedule that will be executed periodically. I have specified the requested branch and scheduled the job successfully, but don't know how to execute only that one test. I know for one pipeline that the guys managed to do it using spring profiles. Test test is annotated in the following way:

@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("local")
@Profile("night")
@IfProfileValue(name = "night", value = "true")
public class NightExecutionTest{

This was enough for execution of this test only. Unfortunately I am not the owner and I can't see the that schedule and it's configuration.

This is the schedule that I have created in gitlab:

enter image description here

Can someone tell what variable maybe I need to pass so this test will be executed only with this schedule, but ignored in every other pipeline?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
f.trajkovski
  • 794
  • 9
  • 24
  • You will need to edit your gitlab.yml config to add a property. You can add a conditional statement to either invoke normal maven/gradle build, or follow advice in the linked duplicate to run just a single test, depending on the presence of that property. Just editing the schedule alone is not going to be enough. – Michael Jul 20 '20 at 22:07
  • There is a way how to do this using spring profiles, where in the end you can specify for which spring profile to be executed in the Schedule tab. Also the point is not to find a maven command how to execute this test only, but how to achieve it via this schedule. There is a solution even without changing the gitlab.yml. – f.trajkovski Jul 20 '20 at 22:14
  • @Michael just an information that there is a way even without changing the gitlab.yml. By using the annotation `@IfProfileValue(name = "night", value = "true")` and by adding variable with name: `ADDITIONAL_MAVEN_BUILD_PARAMETERS` and value `-Ddemo=true `Dtest=NightExecutionTest` you can execute only this test. Will vote for opening this question and give this as an answer. – f.trajkovski Sep 02 '20 at 08:16

0 Answers0