There is a known problem that in Gitlab it's not possible to avoid pipeline duplication in some scenarios.
Let's assume you combine merge and branch pipelines. You can follow the Gitlab guideline or here is an improved one:
workflow:
remove-stale-branches: | |
needs: [] | |
image: python:slim | |
variables: | |
THRESHOLD_PERIOD_DAYS: 30 | |
STALE_PROJECT_NAMESPACES: "$CI_PROJECT_PATH" | |
parallel: | |
matrix: | |
- STALE_PROJECT_NAMESPACES: "foo/baz" | |
STALE_EXCLUSION_PATTERNS: "example/.*" |
#!/usr/bin/env bash | |
read version | |
url="https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/$version/spring-boot-dependencies-$version.pom" | |
properties_lines=$(curl -s "$url" | sed -n '/<properties>/,/<\/properties>/p' | sed -e 's/<properties>//;s/<\/properties>//') | |
echo "$properties_lines" |
There is a known problem that in Gitlab it's not possible to avoid pipeline duplication in some scenarios.
Let's assume you combine merge and branch pipelines. You can follow the Gitlab guideline or here is an improved one:
workflow:
@Configuration | |
@EnableConfigurationProperties(ExampleParentProperties::class) | |
class ExampleConfiguration {} | |
@ConstructorBinding | |
@ConfigurationProperties(prefix = "io.github.artemptushkin.example") | |
data class ExampleParentProperties( | |
val child: ChildProperties = ChildProperties() | |
) |
@Bean | |
public HttpStatus defaultStatus() { | |
return HttpStatus.INTERNAL_SERVER_ERROR; | |
} |
public class ReactiveExceptionHandler extends AbstractErrorWebExceptionHandler { | |
private final Map<Class<? extends Exception>, HttpStatus> exceptionToStatusCode; | |
private final HttpStatus defaultStatus; | |
public ReactiveExceptionHandler(ErrorAttributes errorAttributes, WebProperties.Resources resources, | |
ApplicationContext applicationContext, Map<Class<? extends Exception>, HttpStatus> exceptionToStatusCode, | |
HttpStatus defaultStatus) { | |
super(errorAttributes, resources, applicationContext); | |
this.exceptionToStatusCode = exceptionToStatusCode; | |
this.defaultStatus = defaultStatus; |
@Bean | |
public Map<Class<? extends Exception>, HttpStatus> exceptionToStatusCode() { | |
return Map.of( | |
CustomExceptionInController.class, HttpStatus.BAD_REQUEST, | |
CustomExceptionInFilter.class, HttpStatus.BAD_REQUEST | |
); | |
} |
@Slf4j | |
@ControllerAdvice | |
@Profile("servlet") | |
@RequiredArgsConstructor | |
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) | |
public class ServletExceptionHandler { | |
private final Map<Class<? extends Exception>, HttpStatus> exceptionToStatusCode; | |
private final HttpStatus defaultStatus; | |
@ExceptionHandler(CustomExceptionInFilter.class) |
@Component | |
@Profile("servlet") | |
@RequiredArgsConstructor | |
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) | |
public class ExceptionHandlingFilter extends OncePerRequestFilter { | |
private final ServletExceptionHandler exceptionHandler; | |
/** | |
* naming this differently than _objectMapper_ you give a chance your code to pass a specific object mapper by the qualifier | |
* the field name will be considered as the name of the bean | |
*/ |
@Component | |
@RequiredArgsConstructor | |
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS) | |
public class HeaderValueProvider implements Supplier<String> { //supplier interface just for the API segregation | |
private final HttpServletRequest httpServletRequest; | |
@Override | |
public String get() { | |
return httpServletRequest.getHeader("someHeader"); | |
} |