diff --git a/Jenkinsfile b/Jenkinsfile index a81cb209c5611f7cac77cbb15d15d70533c24390..045325e7eebbaf244aeca66758bb24ae4e80fa11 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,19 +1,117 @@ pipeline { - environment { - BRANCH_TO_DEPLOY = "master" - } agent none + parameters { + booleanParam( + name: 'SNYK_TEST', + defaultValue: true, + description: 'Do you want to run Snyk tests?' + ) + booleanParam( + name: 'RELEASE_INPUT', + defaultValue: false, + description: 'Do you want to release this version? (Only relevant if branch is master or release/*)' + ) + } + options { + timeout(time: 1, unit: 'HOURS') + buildDiscarder( + logRotator( + numToKeepStr: '10', + artifactNumToKeepStr: '3' + ) + ) + ansiColor('xterm') + } + triggers { + cron('@weekly') + } stages { + stage('Checkout') { + agent { + label 'docker' + } + steps { + checkout scm + sh 'git fetch --prune --tags' + } + } + stage('Verify') { + agent { + label 'docker' + } + steps { + sh 'mvn clean verify' + } + } + stage('Snyk test') { + agent { + label 'docker' + } + when { + expression { return params.SNYK_TEST } + } + steps { + sh 'mvn snyk:test' + } + } stage('Deploy') { agent { label 'docker' } when { - branch "${BRANCH_TO_DEPLOY}" + anyOf { + branch 'master' + branch pattern: 'release/*' + } + not { + expression { return params.RELEASE_INPUT } + } + } + steps { + sh 'mvn deploy' + } + } + stage('Snyk monitor') { + agent { + label 'docker' + } + when { + anyOf { + branch 'master' + branch pattern: 'release/*' + } + expression { return params.SNYK_TEST } + } + steps { + sh 'mvn snyk:monitor' + } + } + stage('Release') { + agent { + label 'docker' + } + when { + allOf { + anyOf { + branch 'master' + branch pattern: 'release/*' + } + expression { return params.RELEASE_INPUT } + } + } + environment { + RELEASE_VERSION = sh( + returnStdout: true, + script: 'mvn help:evaluate -Dexpression=project.version -q -DforceStdout' + ).trim().replace('-SNAPSHOT','') } steps { - // Just get helm3 for testing - sh 'wget https://get.helm.sh/helm-v3.0.3-linux-amd64.tar.gz https://get.helm.sh/helm-v3.0.3-linux-amd64.tar.gz.sha256' + sh "git checkout ${BRANCH_NAME}" + sh 'mvn release:prepare release:perform -V' + script { + currentBuild.description = "Release ${RELEASE_VERSION}" + currentBuild.keepLog = true + } } } } diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..993f97770714f46c110365ca12876dd92bc13242 --- /dev/null +++ b/pom.xml @@ -0,0 +1,880 @@ + + + 4.0.0 + + com.joaolino + demo-infra-demo-test + 1.0-SNAPSHOT + pom + + Demo Infra Demo Test + Test pom project builds. + + + João Lino + https://www.joaolino.com + + + + scm:git:https://www.joaolino.com/gitlab/demo/demo-infra-demo-test.git + scm:git:https://www.joaolino.com/gitlab/demo/demo-infra-demo-test.git + scm:git:https://www.joaolino.com/gitlab/demo/demo-infra-demo-test.git + + + + GitLab + https://www.joaolino.com/gitlab/demo/demo-infra-demo-test/-/issues/ + + + Jenkins + https://joaolino.com/jenkins/job/demo/job/demo%252Fdemo-infra-demo-test/ + + + + + nexus-releases + João Lino demo release repository + https://joaolino.com/nexus/content/repositories/releases/ + default + + + nexus-snapshots + João Lino demo snapshot repository + https://joaolino.com/nexus/content/repositories/snapshots/ + default + + + + + 11 + + ${java.version} + ${java.version} + UTF-8 + UTF-8 + @ + + 2.2.6.RELEASE + Hoxton.RELEASE + 1.2.25 + ${java.version} + + + + + + + + org.springframework.boot + spring-boot-starter-parent + ${spring-boot.version} + pom + import + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + org.springdoc + springdoc-openapi-ui + ${springdoc.version} + + + + + com.joaolino + demo-spring-common-error + ${project.version} + + + com.joaolino + demo-spring-common-stream + ${project.version} + + + + + + + + + + + + + + + true + ${basedir}/src/main/resources + + **/application*.yml + **/application*.yaml + **/application*.properties + + + + ${basedir}/src/main/resources + + **/application*.yml + **/application*.yaml + **/application*.properties + + + + + + + maven-compiler-plugin + + true + + + + maven-failsafe-plugin + + + + integration-test + verify + + + + + ${project.build.outputDirectory} + + + + maven-war-plugin + + + + + ${start-class} + true + + + + + + org.codehaus.mojo + exec-maven-plugin + + + ${start-class} + + + + maven-resources-plugin + + + ${resource.delimiter} + + false + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + repackage + + repackage + + + + + + ${start-class} + + + + com.github.ekryd.sortpom + sortpom-maven-plugin + 2.11.0 + + + verify + + sort + + + + + + true + true + false + \n + false + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + + + org.apache.maven.plugins + maven-antrun-plugin + + + org.apache.maven.plugins + maven-clean-plugin + 3.1.0 + + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.2 + + + + look-for-unnecessary-or-unused-dependencies + + analyze-only + + + false + + + com.google.code.findbugs:jsr305 + javax.inject:javax.inject + io.gatling:gatling-commons + io.gatling:gatling-core + io.gatling:gatling-app + io.gatling:gatling-http + io.gatling:gatling-test-framework + io.gatling.highcharts:gatling-charts-highcharts + mysql:mysql-connector-java + org.apache.activemq:activemq-openwire-legacy + org.apache.logging.log4j:log4j-core + org.apache.logging.log4j:log4j-slf4j-impl + org.eclipse.jetty:jetty-util + org.eclipse.jetty:jetty-http + org.glassfish.hk2.external:javax.inject + org.glassfish.jersey.containers:jersey-container-jetty-http + org.glassfish.jersey.core:jersey-client + org.glassfish.jersey.ext:jersey-bean-validation + org.hibernate.validator:hibernate-validator + javax.el:javax.el-api + org.glassfish.jersey.inject:jersey-hk2 + org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-jetty + org.slf4j:slf4j-api + javax.servlet:javax.servlet-api + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + true + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + enforce-banned-dependencies + + enforce + + + + + + + com.h2database + junit + org.mockito + + ch.qos.logback + + log4j:log4j + org.slf4j:log4j-over-slf4j + + + + com.h2database:*:*:jar:test + junit:*:*:jar:test + org.mockito:*:*:jar:test + io.gatling.*:*:*:jar:test + + + + true + + + + enforce-maven-version + + enforce + + + + + 3.6.0 + + + + + + + + org.apache.maven.plugins + maven-help-plugin + 3.2.0 + + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + default-jar + + jar + + + + + + ${start-class} + true + true + + + + ${git.commit.id} + + ${git.commit.id.describe} + + ${git.remote.origin.url} + + + + + + create-test-jar + + test-jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.1.0 + + + javadoc + process-sources + + javadoc + + + + + true + true + ${project.reporting.outputEncoding} + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + false + demo-spring-@{project.version} + deploy + + + + org.apache.maven.plugins + maven-shade-plugin + + + package + + shade + + + + + META-INF/spring.handlers + + + META-INF/spring.factories + + + META-INF/spring.schemas + + + + + ${start-class} + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + true + true + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.0 + + true + + target/log + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + + default-prepare-agent + + prepare-agent + + + + + default-prepare-agent-integration + + prepare-agent-integration + + + + + default-merge + verify + + merge + + + ${project.build.directory}/jacoco-merged.exec + + + ${project.build.directory} + + *.exec + + + + + + + default-report + + report + + + + default-report-integration + + report-integration + + + + merged-report + + report + + + ${project.build.directory}/jacoco-merged.exec + ${project.reporting.outputDirectory}/jacoco-merged + + + + + default-check + + check + + + ${project.build.directory}/jacoco-merged.exec + true + + + BUNDLE + + + + INSTRUCTION + COVEREDRATIO + 85% + + + + CLASS + MISSEDCOUNT + 0 + + + + + BUNDLE + + + + COMPLEXITY + COVEREDRATIO + 0.69 + + + + + + + + + + + pl.project13.maven + git-commit-id-plugin + 2.2.4 + + + get-the-git-infos + + revision + + + + + validate-the-git-infos + + package + + validateRevision + + + + + + yyyy-MM-dd'T'HH:mm:ssZ + false + true + ${project.build.outputDirectory}/git.properties + properties + true + true + true + true + false + false + + ^git.branch$ + ^git.build.host$ + ^git.build.time$ + ^git.build.user.email$ + ^git.build.user.name$ + ^git.build.version$ + ^git.closest.tag.commit.count$ + ^git.closest.tag.name$ + ^git.commit.id$ + ^git.commit.id.describe$ + ^git.commit.time$ + ^git.commit.user.email$ + ^git.dirty$ + ^git.remote.origin.url$ + ^git.tags$ + + false + + false + false + 7 + -dirty + * + false + false + + HEAD + + + + io.snyk + snyk-maven-plugin + 1.2.6 + + true + + ${SNYK_TOKEN} + false + + + + + + + + com.github.ekryd.sortpom + sortpom-maven-plugin + + + + maven-compiler-plugin + 3.8.1 + + + default-compile + compile + + compile + + + true + + + + default-testCompile + test-compile + + testCompile + + + true + + + + + true + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + org.apache.maven.plugins + maven-enforcer-plugin + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M4 + + + true + + + + + org.apache.maven.plugins + maven-release-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + remove-project-artifact + pre-clean + + remove-project-artifact + + + + + + org.jacoco + jacoco-maven-plugin + + + pl.project13.maven + git-commit-id-plugin + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + checkstyle + + + + + google_checks.xml + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + javadoc + test-javadoc + + + + + true + true + ${project.reporting.outputEncoding} + -html5 + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.21.0 + + + org.jacoco + jacoco-maven-plugin + + + jacoco-merged + + report + + + ${project.build.directory}/jacoco-merged.exec + jacoco-merged + + + + + + org.kuali.maven.plugins + graph-maven-plugin + 1.2.3 + + + + org.owasp + dependency-check-maven + 1.4.3 + + + + + aggregate + + + + + false + + ALL + + + + + + + + snyk-dependency-tests + + + snykTests + + + + + + io.snyk + snyk-maven-plugin + + + snyk-test + test + + test + + + + snyk-monitor + install + + monitor + + + + + + + + +