diff --git a/.githubignore b/.githubignore new file mode 100644 index 0000000..49285d0 --- /dev/null +++ b/.githubignore @@ -0,0 +1,4 @@ +LICENSE_HEADER +pipeline.dev.jenkinsfile +pipeline.github.jenkinsfile +pipeline.release.jenkinsfile \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d215e03 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*/.classpath +*/.project +*/target +*/*.log +.idea/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cd46414 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2022 gematik GmbH + +Licensed under the Apache License, Version 2.0 (the License); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an 'AS IS' BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/LICENSE_HEADER b/LICENSE_HEADER new file mode 100644 index 0000000..49fb4b1 --- /dev/null +++ b/LICENSE_HEADER @@ -0,0 +1,4 @@ +/* + * ${GEMATIK_COPYRIGHT_STATEMENT} + */ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..b8186c7 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Gematik Reference Validator + +- TODO \ No newline at end of file diff --git a/ReleaseNotes.md b/ReleaseNotes.md new file mode 100644 index 0000000..cdd8591 --- /dev/null +++ b/ReleaseNotes.md @@ -0,0 +1,3 @@ +# Release 0.1.0 + +- TODO \ No newline at end of file diff --git a/jenkinsfile.dev b/jenkinsfile.dev new file mode 100644 index 0000000..f50c00f --- /dev/null +++ b/jenkinsfile.dev @@ -0,0 +1,141 @@ +@Library('gematik-jenkins-shared-library') _ + +def CREDENTIAL_ID_GEMATIK_GIT = 'GITLAB.tst_tt_build.Username_Password' +def BRANCH = 'master' +def JIRA_PROJECT_ID = 'REFV' +def GITLAB_PROJECT_ID = '1057' +def TAG_NAME = 'ci-build' +def POM_PATH = 'de.gematik.refv/pom.xml' +def DOCKER_FILE = "Dockerfile" +def IMAGE_NAME = "refv/referencevalidator" +def DOCKER_VERSION = "latest" + +pipeline { + + options { + disableConcurrentBuilds() + } + agent { label 'k8-maven' } + + stages { + stage('Get Jira Version') { + steps { + script { + JIRA_VERSION = jiraCheckAndGetSingleVersion(jiraGetVersions(JIRA_PROJECT_ID)) + } + } + } + + stage('Generate Feature Tag') { + when { not { branch BRANCH } } + steps { + script { + DOCKER_VERSION = extendsVersionWithFeatureBranch() + } + } + } + + stage('gitCreateBranch') { + when { branch BRANCH } + steps { + gitCreateBranch() + } + } + + stage('set Version') { + steps { + mavenSetVersionFromJiraProject(JIRA_PROJECT_ID, POM_PATH) + } + } + + stage('Build') { + steps { + mavenBuild(POM_PATH) + } + } + + stage('Test') { + steps { + mavenTest(POM_PATH) + } + } + + stage('OWASP') { + steps { + mavenOwaspScan(POM_PATH) + } + } + + stage('Sonar') { + steps { + mavenCheckWithSonarQube(POM_PATH, "", false) + } + } + + stage('deploy') { + when { branch BRANCH } + steps { + mavenDeploy(POM_PATH) + } + } + +// stage('DockerBuild') { +// steps { +// dockerBuild(IMAGE_NAME, DOCKER_VERSION, JIRA_VERSION, "", DOCKER_FILE) +// } +// } +// +// stage('Switch to Docker-Agent') { +// agent { label 'k8-docker' } +// stages { +// stage('Vulnerabilities-Scan Report with ALL') { +// steps { +// trivyVulnerabilitiesScanAllAsHtml(IMAGE_NAME, DOCKER_VERSION) +// } +// } +// stage('Vulnerabilities-Scan LOW,MEDIUM') { +// steps { +// trivyVulnerabilitiesScanLowMedium(IMAGE_NAME, DOCKER_VERSION) +// } +// } +// stage('Vulnerabilities-Scan HIGH,CRITICAL') { +// steps { +// trivyVulnerabilitiesScanHighCritical(IMAGE_NAME, DOCKER_VERSION, 1) +// } +// } +// stage('Vulnerabilities-Scan Unfixed CRITICAL') { +// steps { +// trivyVulnerabilitiesScanCriticalUnfixed(IMAGE_NAME, DOCKER_VERSION) +// } +// } +// } +// } +// +// stage('push Dockerimage') { +// when { branch BRANCH } +// steps { +// dockerPushImage(IMAGE_NAME, DOCKER_VERSION) +// } +// } + + stage('Tag and Push CI-build') { + when { branch BRANCH } + steps { + gitCreateAndPushTag(JIRA_PROJECT_ID) + } + } + + stage('GitLab-Update-Snapshot') { + when { branch BRANCH } + steps { + gitLabUpdateMavenSnapshot(JIRA_PROJECT_ID, GITLAB_PROJECT_ID, POM_PATH) + } + } + } + post { + always { +// dockerRemoveLocalImage(IMAGE_NAME, DOCKER_VERSION) + } + } + +} \ No newline at end of file diff --git a/jenkinsfile.github b/jenkinsfile.github new file mode 100644 index 0000000..b0748a4 --- /dev/null +++ b/jenkinsfile.github @@ -0,0 +1,5 @@ +@Library('gematik-jenkins-shared-library') _ +pipelineGitHubPublish { + GITHUB_PROJECT_NAME = 'reference-validator' + GEMATIK_PROJECT_NAME = 'tools/gematik-referenzvalidator.git' +} \ No newline at end of file diff --git a/jenkinsfile.release b/jenkinsfile.release new file mode 100644 index 0000000..b06aec6 --- /dev/null +++ b/jenkinsfile.release @@ -0,0 +1,102 @@ +@Library('gematik-jenkins-shared-library') _ + +def CREDENTIAL_ID_GEMATIK_GIT = 'GITLAB.tst_tt_build.Username_Password' +def REPO_URL = createGitUrl('git/refImpl/tools/gematik-referenzvalidator.git') +def BRANCH = 'master' +def JIRA_PROJECT_ID = 'REFV' +def GITLAB_PROJECT_ID = '1057' +def TITLE_TEXT = 'Release' +def ARTIFACT_ID = "de.gematik.refv.reference-validator" +def ARTIFACT_ID_LIST = "de.gematik.refv.reference-validator" +def GROUP_ID_PATH = "de/gematik" +def GROUP_ID = "de.gematik" +def POM_PATH = 'de.gematik.refv.referencevalidator/pom.xml' +def IMAGE_NAME = "refv/referencevalidator" +def DOCKER_PULL_VERSION = "latest" + +pipeline { + options { + disableConcurrentBuilds() + buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5') + } + agent { label 'k8-maven' } + + parameters { + //!!! RELEASE_VERION ist ein Eingabeparameter in Jenkins (siehe https://wiki.gematik.de/pages/viewpage.action?pageId=442577145#JenkinsReleasePipeline(Executables)-Nutzereingaben ) + string(name: 'NEW_VERSION', defaultValue: '', description: 'Bitte die nächste Version für das Projekt eingeben, format [0-9]+.[0-9]+.[0-9]+ \nHinweis: Version 0.0.[0-9] ist keine gültige Version!') + } + + stages { + stage('Initialise') { + steps { + checkVersion(NEW_VERSION) // Eingabe erfolgt über Benutzerinteraktion beim Start des Jobs + } + } + + stage('Checkout') { + steps { + git branch: BRANCH, + credentialsId: CREDENTIAL_ID_GEMATIK_GIT, + url: REPO_URL + } + } + + + stage('Environment') { + environment { + LATEST = nexusGetLatestVersion(RELEASE_VERSION, ARTIFACT_ID, GROUP_ID).trim() + TAG_NAME = 'Release/ReleaseBuild' + } + stages { + stage('Create Release-Tag') { + steps { + gitCreateAndPushTag(JIRA_PROJECT_ID, "${TAG_NAME}-${LATEST}", BRANCH) + } + } + + stage('Create GitLab Release') { + steps { + gitLabCreateRelease(JIRA_PROJECT_ID, GITLAB_PROJECT_ID, LATEST, ARTIFACT_ID, GROUP_ID_PATH, TITLE_TEXT, RELEASE_VERSION, "${TAG_NAME}-${LATEST}") + } + } + + stage('Release Jira-Version') { + steps { + jiraReleaseVersion(JIRA_PROJECT_ID, RELEASE_VERSION) + } + } + stage('Create New Jira-Version') { + steps { + jiraCreateNewVersion(JIRA_PROJECT_ID, NEW_VERSION) + } + } + stage('UpdateProject with new Version') { + steps { + mavenSetVersion("${NEW_VERSION}-SNAPSHOT", POM_PATH) + gitPushVersionUpdate(JIRA_PROJECT_ID, "${NEW_VERSION}-SNAPSHOT", BRANCH) + } + } + stage('deleteOldArtifacts') { + steps { + nexusDeleteArtifacts(RELEASE_VERSION, ARTIFACT_ID_LIST, GROUP_ID) + } + } + +// stage('Retag Docker Image'){ +// steps { +// script { +// dockerPull(IMAGE_NAME, DOCKER_PULL_VERSION) +// dockerReTagImage(IMAGE_NAME, RELEASE_VERSION) +// dockerPushImage(IMAGE_NAME, RELEASE_VERSION) +// } +// } +// } + } + } + } + post { + always { +// dockerRemoveLocalImage(IMAGE_NAME, RELEASE_VERSION) + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..34d53d2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + de.gematik.refv + referencevalidator + jar + 0.0.1-SNAPSHOT + gematik Referenzvalidator + https://github.com/gematik/referencevalidator + + + + Apache License 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + UTF-8 + 11 + 11 + + + + junit + junit + 3.8.1 + test + + + diff --git a/src/main/java/de/gematik/refv/App.java b/src/main/java/de/gematik/refv/App.java new file mode 100644 index 0000000..718b10f --- /dev/null +++ b/src/main/java/de/gematik/refv/App.java @@ -0,0 +1,13 @@ +package de.gematik.refv; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +}