Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 1 addition & 3 deletions .s2i/environment
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
S2I_DESTINATION=/tmp
MAVEN_ARGS_APPEND=-Dmaven.repo.local=/tmp/src/artifacts/m2 -o
DISABLE_ARTIFACTS=true
S2I_DESTINATION=/tmp
9 changes: 0 additions & 9 deletions Dockerfile-on-prem

This file was deleted.

119 changes: 0 additions & 119 deletions Jenkinsfile-on-prem

This file was deleted.

79 changes: 9 additions & 70 deletions Jenkinsfile-online
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ pipeline {

environment {
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
GITHUB_CREDENTIAL_ID = 'github-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'docker.io'
DOCKERHUB_NAMESPACE = 'docker_username'
GITHUB_ACCOUNT = 'kubesphere'
DOCKERHUB_NAMESPACE = 'tanjunjie'
GITHUB_ACCOUNT = 'tanjunjie'
APP_NAME = 'devops-java-sample'
SONAR_CREDENTIAL_ID= 'sonar-token'
}

stages {
Expand All @@ -30,90 +27,32 @@ pipeline {
stage ('unit test') {
steps {
container ('maven') {
sh 'mvn clean -o -gs `pwd`/configuration/settings.xml test'
sh 'mvn clean test'
}
}
}

stage('sonarqube analysis') {
steps {
container ('maven') {
withCredentials([string(credentialsId: "$SONAR_CREDENTIAL_ID", variable: 'SONAR_TOKEN')]) {
withSonarQubeEnv('sonar') {
sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN"
}
}
timeout(time: 1, unit: 'HOURS') {
waitForQualityGate abortPipeline: true
}
}
}
}

stage ('build & push') {
steps {
container ('maven') {
sh 'mvn -o -Dmaven.test.skip=true -gs `pwd`/configuration/settings.xml clean package'
sh 'docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .'
sh 'mvn -Dmaven.test.skip=true clean package'
archiveArtifacts 'target/*.jar'
sh 'docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER .'
withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$DOCKER_CREDENTIAL_ID" ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}

stage('push latest'){
when{
branch 'master'
}
steps{
container ('maven') {
sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest '
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:latest '
sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:cache '
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:cache '
}
}
}

stage('deploy to dev') {
when{
branch 'master'
}
steps {
input(id: 'deploy-to-dev', message: 'deploy to dev?')
kubernetesDeploy(configs: 'deploy/dev-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
stage('push with tag'){
when{
expression{
return params.TAG_NAME =~ /v.*/
}
}
steps {
container ('maven') {
input(id: 'release-image-with-tag', message: 'release image with tag?')
withCredentials([usernamePassword(credentialsId: "$GITHUB_CREDENTIAL_ID", passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh 'git config --global user.email "kubesphere@yunify.com" '
sh 'git config --global user.name "kubesphere" '
sh 'git tag -a $TAG_NAME -m "$TAG_NAME" '
sh 'git push http://$GIT_USERNAME:$GIT_PASSWORD@github.com/$GITHUB_ACCOUNT/devops-java-sample.git --tags --ipv4'
}
sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME '
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$TAG_NAME '
}
}
}
stage('deploy to production') {
when{
expression{
return params.TAG_NAME =~ /v.*/
}
}
steps {
input(id: 'deploy-to-production', message: 'deploy to production?')
kubernetesDeploy(configs: 'deploy/prod-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
}
}
4 changes: 0 additions & 4 deletions artifacts/m2/antlr/antlr/2.7.2/_remote.repositories

This file was deleted.

Binary file removed artifacts/m2/antlr/antlr/2.7.2/antlr-2.7.2.jar
Binary file not shown.
1 change: 0 additions & 1 deletion artifacts/m2/antlr/antlr/2.7.2/antlr-2.7.2.jar.sha1

This file was deleted.

6 changes: 0 additions & 6 deletions artifacts/m2/antlr/antlr/2.7.2/antlr-2.7.2.pom

This file was deleted.

1 change: 0 additions & 1 deletion artifacts/m2/antlr/antlr/2.7.2/antlr-2.7.2.pom.sha1

This file was deleted.

4 changes: 0 additions & 4 deletions artifacts/m2/aopalliance/aopalliance/1.0/_remote.repositories

This file was deleted.

Binary file not shown.

This file was deleted.

15 changes: 0 additions & 15 deletions artifacts/m2/aopalliance/aopalliance/1.0/aopalliance-1.0.pom

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions artifacts/m2/asm/asm-analysis/3.2/_remote.repositories

This file was deleted.

Binary file not shown.

This file was deleted.

21 changes: 0 additions & 21 deletions artifacts/m2/asm/asm-analysis/3.2/asm-analysis-3.2.pom

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions artifacts/m2/asm/asm-commons/3.2/_remote.repositories

This file was deleted.

21 changes: 0 additions & 21 deletions artifacts/m2/asm/asm-commons/3.2/asm-commons-3.2.pom

This file was deleted.

1 change: 0 additions & 1 deletion artifacts/m2/asm/asm-commons/3.2/asm-commons-3.2.pom.sha1

This file was deleted.

4 changes: 0 additions & 4 deletions artifacts/m2/asm/asm-commons/3.3.1/_remote.repositories

This file was deleted.

Binary file not shown.

This file was deleted.

21 changes: 0 additions & 21 deletions artifacts/m2/asm/asm-commons/3.3.1/asm-commons-3.3.1.pom

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions artifacts/m2/asm/asm-parent/3.2/_remote.repositories

This file was deleted.

Loading