Discord Script

Discord Script usage

Usage:

  • Copy the script at the root of your project (as send.sh)
  • Define a global variable for WEBHOOK_URL
  • Create according jobs for notifications
  • Modify/Create rules for execution of each notification job

Example notification stage

stages:
  - notification
success_notification:
  stage: notification
  script:
    - chmod +x send.sh
    - ./send.sh success $WEBHOOK_URL
  when: on_success
failure_notification:
  stage: notification
  script:
    - chmod +x send.sh
    - ./send.sh failure $WEBHOOK_URL
  when: on_failure

Discord Script to be used in pipeline

[Read More]

Dokku

Dokku and mi-git usage

Deployment

.gitlab-ci.yml (extract)

# Name of the job
deploy-job:
  # Stage of the job execution 
  stage: deploy
  # Image to use for job. Here we use the officila dokku image,
  # https://dokku.com/docs/deployment/continuous-integration/gitlab-ci/
  image: dokku/ci-docker-image:0.15.1
  # Setting some variables, local to the job
  variables:
    # We don't need history, just the last version
    GIT_DEPTH: 0
    # The name of our application, here we use something for our preprod
    # It will result in https://$APP_NAME.dokku.tecture.de as URL
    APP_NAME: geisel-spring-app-staging
  # Restrict the job to dev branch
  only:
    - dev
  # The script of the job. Here we deploy
  script: 
    - dokku-deploy

system.properties (needed at the application root to define the right java version)

[Read More]

Spring

Resources for Spring

Spring

Initialization

Im1

Thymeleaf

Running a specific environment

Config files

Examples:

application-production.properties

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/db
spring.datasource.username=root
spring.datasource.password=root

application-staging.properties

spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
spring.datasource.username=sa
spring.datasource.password=sa

pom.xml

	<profiles>
		<profile>
			<id>dev</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.springframework.boot</groupId>
						<artifactId>spring-boot-maven-plugin</artifactId>
						<configuration>
							<profiles>
								<profile>dev</profile>
							</profiles>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>prod</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.springframework.boot</groupId>
						<artifactId>spring-boot-maven-plugin</artifactId>
						<configuration>
							<profiles>
								<profile>prod</profile>
							</profiles>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

Running specific

Dev environment

  • Locally with spring-boot:run
    • $ mvn spring-boot:run -Pdev
  • Locally with the produced jar
    • $ java -jar -Dspring.profiles.active=dev myapp.jar

Production environment

[Read More]

Unleash

Resources for unleash

Unleash

pom.xml

		<dependencies>
			<dependency>
				<plugin>
					<groupId>io.getunleash</groupId>
					<artifactId>unleash-client-java</artifactId>
					<version>9.1.0</version>
				</plugin>
			</dependency>
		</dependencies>

Code examples

UnleashConfig config = UnleashConfig.builder()
        .appName("my.java-app") // name of your running environment (e.g. activeProfile)
        .instanceId("InstanceID_FROM_GUTLAB")
        .unleashAPI("API_URL_FROM_GITLAB")
        .build();

Unleash unleash = new DefaultUnleash(config);
if(unleash.isEnabled("AwesomeFeature")) {
  //do some magic
} else {
  //do old boring stuff
}

Other Resources