Skip to content
Open
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.

124 changes: 15 additions & 109 deletions Jenkinsfile-online
Original file line number Diff line number Diff line change
@@ -1,119 +1,25 @@
pipeline {
agent {
node {
label 'maven'
//agent {label 'local-slave'}
agent any

environment {
def registry_url = "hub.xxx.com"
def imageName = "${group_id}/${project_name}"
def build_tag = "${registry_url}/${group_id}/${project_name}:${img_tag}"
}
}

parameters {
string(name:'TAG_NAME',defaultValue: '',description:'')
choice(choices: 'A\nB', description: '测试一下', name: 'project_name')
choice(choices: 'RD\nQA\nPRE\nONLINE', description: '环境选择', name: 'runer_env')
choice(choices: '发布\n回滚', description: '动作选择', name: '执行动作')
string(defaultValue: 'v0.0.1', name: 'TAG_NAME')
//string(name:'git_url',defaultValue: 'xxxx',description: 'git工程路径')
string(name:'group_id', defaultValue: 'idc', description: '业务小组')
}

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'
APP_NAME = 'devops-java-sample'
SONAR_CREDENTIAL_ID= 'sonar-token'
}

stages {
stage ('checkout scm') {
steps {
checkout(scm)
}
}

stage ('unit test') {
stage('build') {
steps {
container ('maven') {
sh 'mvn clean -o -gs `pwd`/configuration/settings.xml 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 .'
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'
}
}
}
}

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 '
}
}
}

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.*/
echo "Hello World!"
}
}
steps {
input(id: 'deploy-to-production', message: 'deploy to production?')
kubernetesDeploy(configs: 'deploy/prod-ol/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# devops-java-sample
A Java sample for devops on kubesphere
test pull
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.

Loading