fix jenkinsfile

This commit is contained in:
Anton Romanov 2022-11-09 11:44:26 +04:00
parent 7d4bb518c6
commit 60326fcd26
4 changed files with 52 additions and 68 deletions

67
Jenkinsfile vendored
View File

@ -1,75 +1,20 @@
// node {
// def app
//
// stage('Clone repository') {
// checkout scm
// }
//
// stage('Build image') {
// app = docker.build("romanov73/is:ng-tracker-container-11")
// }
//
// stage('Test image') {
// sh ./gradlew bootRun -Dng-tracker.check-run=true
// app.inside {
// sh 'echo "Tests passed"'
// }
// }
// }
//
// pipeline {
// agent none stages {
// stage('Maven Install') {
// agent {
// docker {
// image 'romanov73/is:ng-tracker-container-11'
// }
// }
// steps {
// sh 'sh ./gradlew bootRun -Dng-tracker.check-run=true'
// }
// }
// stage('Docker Build') {
// agent any
// steps {
// sh 'docker build -t shanem/spring-petclinic:latest .'
// }
// }
// }
// }
pipeline {
/*agent any
agent {
docker {
image 'romanov73/is:ng-tracker-container-11'
}
}
stages {
stage('Cloning Git') {
steps {
git([url: 'https://git.athene.tech/romanov73/example-web.git', branch: 'master'])
}
}
stage('Build') {
steps{
script {
docker.image('romanov73/is:ng-tracker-container-11').inside {
sh 'bash ./gradlew test'
}
}
}*/
agent { docker { image 'romanov73/is:ng-tracker-container-11' } }
stages {
stage('Cloning Git') {
steps {
git([url: 'https://gitlab.com/romanov73/ng-tracker.git', branch: 'master'])
}
}
stage('Test') {
steps {
sh 'java -version'
sh 'bash ./gradlew bootRun -Dng-tracker.check-run=true'
sh 'bash ./gradlew bootRun -Dexample-web.check-run=true'
}
}
}
//}
// }
// }
}

View File

@ -2,12 +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.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.event.EventListener;
import ru.ulstu.configuration.ApplicationProperties;
@SpringBootApplication
@EnableConfigurationProperties
public class ExampleWebApplication {
private final ApplicationProperties applicationProperties;
public ExampleWebApplication(ApplicationProperties applicationProperties) {
this.applicationProperties = applicationProperties;
}
public static void main(String[] args) {
SpringApplication.run(ExampleWebApplication.class, args);
}
@EventListener(ApplicationReadyEvent.class)
public void doSomethingAfterStartup() {
System.out.println(applicationProperties.isCheckRun());
if (applicationProperties.isCheckRun()) {
System.exit(0);
}
}
}

View File

@ -0,0 +1,20 @@
package ru.ulstu.configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
@Component
@ConfigurationProperties(prefix = "example-web")
@Validated
public class ApplicationProperties {
private boolean checkRun;
public boolean isCheckRun() {
return checkRun;
}
public void setCheckRun(boolean checkRun) {
this.checkRun = checkRun;
}
}

View File

@ -1,2 +1,3 @@
spring.main.banner-mode=off
server.port=8080
example-web.check-run=false