diff --git a/.gitignore b/.gitignore index d8fe0c5..5f3acb0 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,5 @@ venv.bak/ # mypy .mypy_cache/ + +.idea diff --git a/Jenkinsfile-online b/Jenkinsfile-online index 8678511..775fe6e 100644 --- a/Jenkinsfile-online +++ b/Jenkinsfile-online @@ -8,7 +8,7 @@ pipeline { DOCKER_CREDENTIAL_ID = 'dockerhub' KUBECONFIG_CREDENTIAL_ID = 'kubeconfig' REGISTRY = 'docker.io' - DOCKERHUB_NAMESPACE = 'shaowenchen' + DOCKERHUB_NAMESPACE = 'kubespheredev' APP_NAME = 'devops-python-sample' SONAR_CREDENTIAL_ID = 'sonar-token' } @@ -20,7 +20,7 @@ pipeline { stage('拉取代码') { steps { container('base') { - checkout([$class: 'GitSCM', branches: [[name: '*/$BRANCH_NAME']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/shaowenchen/devops-python-sample.git']]]) + checkout([$class: 'GitSCM', branches: [[name: '*/$BRANCH_NAME']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/kubesphere/devops-python-sample.git']]]) } /* if in scm, you can use: checkout scm */ } @@ -32,11 +32,11 @@ pipeline { withCredentials([string(credentialsId : "$SONAR_CREDENTIAL_ID" ,variable : 'SONAR_TOKEN' ,)]) { withSonarQubeEnv('sonar') { sh '''pip install pkgs/base/* & pip install pkgs/extra/* - coverage erase - cd ./src/ - coverage run --source='.' manage.py test - coverage xml -i - ''' + coverage erase + cd ./src/ + coverage run --source='.' manage.py test + coverage xml -i + ''' sh "sonar-scanner -Dsonar.branch=$BRANCH_NAME -Dsonar.login=$SONAR_TOKEN" } @@ -63,7 +63,12 @@ pipeline { stage('部署') { steps { - kubernetesDeploy(enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID", configs: 'deploy/**') + container ('base') { + withCredentials([kubeconfigFile(credentialsId: env.KUBECONFIG_CREDENTIAL_ID, variable: 'KUBECONFIG')]) { + sh 'envsubst < deploy/devops-sample.yaml | kubectl apply -f -' + sh 'envsubst < deploy/devops-sample-svc.yaml | kubectl apply -f -' + } + } } }