From a39fcf2c5ea4ea431896b7cd40d6ef7db651aa25 Mon Sep 17 00:00:00 2001 From: Patrik Dufresne Date: Wed, 16 Jan 2019 15:01:08 +0000 Subject: [PATCH] TASK-1081 Add gitlab cicd --- .classpath | 31 ----------- .gitignore | 5 +- .gitlab-ci.yml | 49 +++++++++++++++++ .project | 23 -------- .settings/org.eclipse.jdt.core.prefs | 5 -- .settings/org.eclipse.m2e.core.prefs | 4 -- Jenkinsfile | 53 ------------------- pom.xml | 36 ++++++------- settings.xml | 27 ++++++++++ src/main/build-tools/formatter.xml | 2 +- src/main/build-tools/license-header.txt | 2 +- .../com/patrikdufresne/license/Base64.java | 2 +- .../license/EncryptionManager.java | 2 +- .../license/KeyBlackListedException.java | 2 +- .../license/KeyInvalidException.java | 2 +- .../patrikdufresne/license/KeyManager.java | 2 +- .../com/patrikdufresne/license/License.java | 2 +- .../license/LicenseException.java | 2 +- .../license/LicenseExpiredException.java | 2 +- .../license/LicenseManager.java | 2 +- .../LicenseVersionExpiredException.java | 2 +- .../patrikdufresne/license/util/ILogger.java | 2 +- .../patrikdufresne/license/util/Policy.java | 2 +- .../com/patrikdufresne/license/AllTests.java | 2 +- .../license/EncryptionManagerTest.java | 2 +- .../license/KeyManagerTest.java | 2 +- .../license/LicenseManagerTest.java | 2 +- 27 files changed, 114 insertions(+), 155 deletions(-) delete mode 100644 .classpath create mode 100644 .gitlab-ci.yml delete mode 100644 .project delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.m2e.core.prefs delete mode 100644 Jenkinsfile create mode 100644 settings.xml diff --git a/.classpath b/.classpath deleted file mode 100644 index f8ce0d3..0000000 --- a/.classpath +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.gitignore b/.gitignore index 5663f73..b32bf56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /target *~ -/*.lic \ No newline at end of file +/*.lic +/.classpath +/.project +/.settings \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..45745fa --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,49 @@ +image: maven:3-jdk-7 + +variables: + MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN + -Dorg.slf4j.simpleLogger.showDateTime=true + -Djava.awt.headless=true + -Dmaven.repo.local=.m2/repository" + +# Cache downloaded dependencies and plugins between builds. +cache: + paths: + - .m2/repository + +stages: + - build + - publish + +before_script: +- export REVISION="$(curl http://git.patrikdufresne.com/pdsl/maven-scm-version/raw/master/version.sh | bash -)" +- echo "REVISION=$REVISION" + +test: + stage: build + script: + - mvn -B -Drevision=${REVISION} clean install + +sonar: + image: maven:3-jdk-8 + stage: build + allow_failure: true + script: + - mvn -B -Drevision=${REVISION} -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN clean verify sonar:sonar + +nexus_deploy: + stage: publish + script: + - mvn -B -s ./settings.xml -Drevision=${REVISION} clean install deploy + +github_push: + stage: publish + script: + - git push --force https://${GITHUB_USR}:${GITHUB_PWD}@github.com/ikus060/${CI_PROJECT_NAME}.git refs/remotes/origin/${CI_COMMIT_REF_NAME}:refs/heads/${CI_COMMIT_REF_NAME} + - git push https://${GITHUB_USR}:${GITHUB_PWD}@github.com/ikus060/${CI_PROJECT_NAME}.git --tags + +gitlab_push: + stage: publish + script: + - git push --force https://${GITLAB_COM_USR}:${GITLAB_COM_PWD}@gitlab.com/pdsl/${CI_PROJECT_NAME}.git refs/remotes/origin/${CI_COMMIT_REF_NAME}:refs/heads/${CI_COMMIT_REF_NAME} + - git push https://${GITLAB_COM_USR}:${GITLAB_COM_PWD}@gitlab.com/pdsl/${CI_PROJECT_NAME}.git --tags diff --git a/.project b/.project deleted file mode 100644 index e38c98b..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - com.patrikdufresne.license - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 60105c1..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 8e53ea3..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,53 +0,0 @@ -pipeline { - environment { - NEXUS = credentials("local-nexus") - GITLAB = credentials("gitlab-jenkins") - GITHUB = credentials("github") - } - parameters { - booleanParam(defaultValue: false, description: 'Generate a release build with a tagged version.', name: 'Release') - } - agent { - docker { - image 'jamesdbloom/docker-java7-maven' - args '-v $HOME/.m2:/root/.m2' - } - } - stages { - stage ('Build') { - steps { - writeFile file: "settings.xml", text: "patrikdufresne${NEXUS_USR}${NEXUS_PSW}" - sh 'mvn --settings settings.xml -U -Dmaven.test.failure.ignore=true clean deploy' - } - } - stage ('Release') { - when { - environment name: 'Release', value: 'true' - } - steps { - script { - // We want to pick up the version from the pom - pom = readMavenPom file: 'pom.xml' - version = pom.version.replace("-SNAPSHOT", "-${BUILD_NUMBER}") - } - sh 'git checkout .' - sh "mvn versions:set -DnewVersion=${version}" - sh "mvn --settings settings.xml -U -Dmaven.test.skip=true deploy" - sh """ - git config --local user.email "jenkins@patrikdufresne.com" - git config --local user.name "Jenkins" - git tag 'v${version}' - export REPO=`git config remote.origin.url` - git push http://${GITLAB}@\044{REPO#*//} --tags - """ - addInfoBadge "v${version}" - } - } - stage('GitHubPush') { - steps { - sh "git push --force https://${GITHUB}@github.com/ikus060/license.git refs/remotes/origin/${BRANCH_NAME}:refs/heads/${BRANCH_NAME}" - sh "git push https://${GITHUB}@github.com/ikus060/license.git --tags" - } - } - } -} diff --git a/pom.xml b/pom.xml index 53f91a5..0395966 100644 --- a/pom.xml +++ b/pom.xml @@ -1,14 +1,15 @@ - + 4.0.0 - com.patrikdufresne.license - com.patrikdufresne.license - 0.9-SNAPSHOT + com.patrikdufresne + license + ${revision} scm:git:http://git.patrikdufresne.com/common/license.git - HEAD - + HEAD + @@ -30,8 +31,8 @@ maven-compiler-plugin 3.0 - 1.6 - 1.6 + 1.7 + 1.7 @@ -80,18 +81,13 @@
src/main/build-tools/license-header.txt
- - - maven-release-plugin - 2.4.2 - - - org.apache.maven.scm - maven-scm-provider-gitexe - 1.8.1 - - - + + + maven-surefire-plugin + + false + + diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..233340e --- /dev/null +++ b/settings.xml @@ -0,0 +1,27 @@ + + + + + patrikdufresne + ${env.NEXUS_USR} + ${env.NEXUS_PWD} + + + \ No newline at end of file diff --git a/src/main/build-tools/formatter.xml b/src/main/build-tools/formatter.xml index 2ce16cf..b291a98 100644 --- a/src/main/build-tools/formatter.xml +++ b/src/main/build-tools/formatter.xml @@ -1,7 +1,7 @@