From bbc398251fe62555a3dce1d96e1ed8d1b3194f34 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 16:16:40 +0400 Subject: [PATCH 1/9] #83 try to change container --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b2fe64..36814a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: ubuntu:18.04 +image: ng-tracker-container cache: key: "$CI_PROJECT_ID" From 4a05d52e4c270f801342acd6c46093df8339b97e Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 16:25:10 +0400 Subject: [PATCH 2/9] #83 try to change container --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36814a3..f60ac81 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: ng-tracker-container +image: romanov73/is:ng-tracker-container cache: key: "$CI_PROJECT_ID" From fe1820d540f69764337d4203e8090b4a47e6dccd Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 16:37:03 +0400 Subject: [PATCH 3/9] #83 try to change container --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f60ac81..ad0d58e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,8 +9,8 @@ variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" before_script: - - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - - apt-get install openjdk-8-jdk git -y +# - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' +# - apt-get install openjdk-8-jdk git -y - eval $(ssh-agent -s) - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh From c7cdbe9044439f42e2371ba7d57822c467f6cdfb Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 17:35:17 +0400 Subject: [PATCH 4/9] #83 add tasks, modify build script for passing application properties --- .gitlab-ci.yml | 20 +++++++++++++++++++ build.gradle | 4 ++++ .../java/ru/ulstu/NgTrackerApplication.java | 17 ++++++++++++++++ .../configuration/ApplicationProperties.java | 12 +++++++++++ src/main/resources/application.properties | 3 ++- 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad0d58e..1d2c728 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,26 @@ build: - build - .gradle +checkRun: + stage: test + script: ./gradlew bootRun -Dng-tracker.check-run=true + cache: + key: "$CI_PROJECT_ID" + policy: push + paths: + - build + - .gradle + +checkStyle: + stage: test + script: ./gradlew check + cache: + key: "$CI_PROJECT_ID" + policy: push + paths: + - build + - .gradle + deploy: stage: deploy script: diff --git a/build.gradle b/build.gradle index 4e0e9cb..ffc7d0a 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,10 @@ bootRun.dependsOn checkstyleMain sourceCompatibility = 1.8 targetCompatibility = 1.8 +bootRun { + systemProperties = System.properties +} + checkstyle { project.ext.checkstyleVersion = '8.8' diff --git a/src/main/java/ru/ulstu/NgTrackerApplication.java b/src/main/java/ru/ulstu/NgTrackerApplication.java index 5e6ee4f..fbe3a2f 100644 --- a/src/main/java/ru/ulstu/NgTrackerApplication.java +++ b/src/main/java/ru/ulstu/NgTrackerApplication.java @@ -2,13 +2,30 @@ package ru.ulstu; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import ru.ulstu.configuration.ApplicationProperties; import ru.ulstu.core.repository.JpaDetachableRepositoryImpl; @SpringBootApplication @EnableJpaRepositories(repositoryBaseClass = JpaDetachableRepositoryImpl.class) public class NgTrackerApplication { + private final ApplicationProperties applicationProperties; + + public NgTrackerApplication(ApplicationProperties applicationProperties) { + this.applicationProperties = applicationProperties; + } + public static void main(String[] args) { SpringApplication.run(NgTrackerApplication.class, args); } + + @EventListener(ApplicationReadyEvent.class) + public void doSomethingAfterStartup() { + System.out.println("hello world, I have just started up"); + if (applicationProperties.isCheckRun()) { + System.exit(0); + } + } } diff --git a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java index 8615cb2..f75f53f 100644 --- a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java +++ b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java @@ -11,12 +11,16 @@ import org.springframework.validation.annotation.Validated; public class ApplicationProperties { @NotBlank private String baseUrl; + @NotBlank private String undeadUserLogin; + private boolean devMode; private boolean useHttps; + private boolean checkRun; + public boolean isUseHttps() { return useHttps; } @@ -48,4 +52,12 @@ public class ApplicationProperties { public void setDevMode(boolean devMode) { this.devMode = devMode; } + + public boolean isCheckRun() { + return checkRun; + } + + public void setCheckRun(boolean checkRun) { + this.checkRun = checkRun; + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fb1b116..038ddcf 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -35,4 +35,5 @@ liquibase.change-log=classpath:db/changelog-master.xml ng-tracker.base-url=http://127.0.0.1:8080 ng-tracker.undead-user-login=admin ng-tracker.dev-mode=true -ng-tracker.use-https=false \ No newline at end of file +ng-tracker.use-https=false +ng-tracker.check-run=false \ No newline at end of file From 7a7dfb337f51c4fdefe54d8b004a85e426d00e74 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 17:41:31 +0400 Subject: [PATCH 5/9] #83 fix postgres service --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d2c728..1436e0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,8 @@ variables: before_script: # - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' # - apt-get install openjdk-8-jdk git -y + - service postgresql stop + - service postgresql start - eval $(ssh-agent -s) - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh From 94dabd07fbd0241b7bbf26c386739ab42498bac1 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 17:47:10 +0400 Subject: [PATCH 6/9] #83 fix code --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1436e0f..404edd9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,8 +9,6 @@ variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" before_script: -# - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' -# - apt-get install openjdk-8-jdk git -y - service postgresql stop - service postgresql start - eval $(ssh-agent -s) From 0feef9016a2dea23be407e425e924ade86ed3bfb Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 17:48:23 +0400 Subject: [PATCH 7/9] #83 disable cache --- .gitlab-ci.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 404edd9..6709891 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,5 @@ image: romanov73/is:ng-tracker-container -cache: - key: "$CI_PROJECT_ID" - paths: - - .gradle/ - variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" @@ -20,32 +15,14 @@ before_script: build: stage: build script: ./gradlew assemble - cache: - key: "$CI_PROJECT_ID" - policy: push - paths: - - build - - .gradle checkRun: stage: test script: ./gradlew bootRun -Dng-tracker.check-run=true - cache: - key: "$CI_PROJECT_ID" - policy: push - paths: - - build - - .gradle checkStyle: stage: test script: ./gradlew check - cache: - key: "$CI_PROJECT_ID" - policy: push - paths: - - build - - .gradle deploy: stage: deploy @@ -53,12 +30,6 @@ deploy: - sh deploy/gdccloud/deploy.sh only: - dev - cache: - key: "$CI_PROJECT_ID" - policy: pull - paths: - - build - - .gradle environment: name: staging url: http://193.110.3.124:8080 From 72add3638b01f111d65e8b645a08936b56c6ee63 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 18:01:12 +0400 Subject: [PATCH 8/9] #83 check CI --- src/main/java/ru/ulstu/paper/model/WrongEntity.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/ru/ulstu/paper/model/WrongEntity.java diff --git a/src/main/java/ru/ulstu/paper/model/WrongEntity.java b/src/main/java/ru/ulstu/paper/model/WrongEntity.java new file mode 100644 index 0000000..85deec8 --- /dev/null +++ b/src/main/java/ru/ulstu/paper/model/WrongEntity.java @@ -0,0 +1,7 @@ +package ru.ulstu.paper.model; + +import javax.persistence.Entity; + +@Entity +public class WrongEntity { +} From e0ca29fbab8ab6d1b6ce5d74ee5de27397584c8b Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 5 Apr 2019 21:47:42 +0400 Subject: [PATCH 9/9] #83 fix wrong entity --- src/main/java/ru/ulstu/paper/model/WrongEntity.java | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/main/java/ru/ulstu/paper/model/WrongEntity.java diff --git a/src/main/java/ru/ulstu/paper/model/WrongEntity.java b/src/main/java/ru/ulstu/paper/model/WrongEntity.java deleted file mode 100644 index 85deec8..0000000 --- a/src/main/java/ru/ulstu/paper/model/WrongEntity.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.ulstu.paper.model; - -import javax.persistence.Entity; - -@Entity -public class WrongEntity { -}