2020年12月8日 | Leave a comment # Azure DevOps CD 配置备忘 ## agent 说明 * 需要安装 JDK11 & Maven 3.6.x * 需要配置 Maven 国内 镜像 ~/.m2/settings.xml </mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> .... </mirrors> * 需要配置 nexus 账号密码 ~/.m2/settings.xml 配置下 nexus 账号密码 <servers> .... <server> <id>t-nexus</id> <username>dev</username> <password>111</password> </server> <server> <id>t-nexus-snapshots</id> <username>dev</username> <password>111</password> </server> ... </servers> ## 配置特殊说明 由于 一个存储库下我们存放了多个项目,各自有不同的 pipeline ,所以貌似不能使用 存储库下的 yaml 文件来配置 使用经典模式配置,可以设置触发目录能达到我们的目的 ## nexus docker 仓库测试 需要允许 http 镜像仓库 "insecure-registries": [ "http://nexus:8082" ], docker tag basic-user-provider:20201208a nexus:8082/basic-user-provider:20201208a docker push nexus:8082/basic-user-provider:20201208a kubectl create secret docker-registry t-nexus \ –docker-server=’http://nexus:8082/’ \ –docker-username=dev \ –docker-password=111\ –docker-email=aa@aa.com kubectl run aa –image=nexus:8082/basic-user-provider:20201208a ## 参考配置 pool: name: javaagent demands: maven timeoutInMinutes: 5 steps: - task: Maven@3 displayName: '单元测试' inputs: mavenPomFile: 'src/common-auth-provider/pom.xml' goals: test - task: Maven@3 displayName: '打包JAR' inputs: mavenPomFile: 'src/common-auth-provider/pom.xml' options: '-DskipTests=true' publishJUnitResults: false - task: Docker@2 displayName: buildAndPush inputs: containerRegistry: docker2 repository: 'common-auth-provider' Dockerfile: 'src/common-auth-provider/devops/Dockerfile' buildContext: 'src/common-auth-provider/target/' - task: KubernetesManifest@0 displayName: deploy inputs: kubernetesServiceConnection: 10.0.4.56 namespace: default manifests: 'src/common-auth-provider/devops/k8s.yaml' containers: 'nexus:8082/common-auth-provider:$(Build.BuildId)' imagePullSecrets: 't-nexus' rolloutStatusTimeout: 120