|
| 1 | +@Library('ops') _ |
| 2 | +def notifier = new com.tamr.jenkins.slack.SlackNotifier() |
| 3 | +def helper = new com.tamr.jenkins.util.JenkinsHelper() |
| 4 | + |
| 5 | +podTemplate( |
| 6 | + containers: [ |
| 7 | + containerTemplate( |
| 8 | + name: 'python-poetry', |
| 9 | + image: 'us-docker.pkg.dev/tamr-docker/ops/python-poetry:latest', |
| 10 | + resourceLimitCpu: "2", |
| 11 | + resourceLimitMemory: "2048Mi", |
| 12 | + resourceRequestCpu: "100m", |
| 13 | + resourceRequestMemory: "1024Mi", |
| 14 | + ttyEnabled: true, |
| 15 | + command: 'cat' |
| 16 | + ), |
| 17 | + containerTemplate( |
| 18 | + name: 'python-poetry-with-java-8', |
| 19 | + image: 'us-docker.pkg.dev/tamr-docker/ops/python-poetry-with-java8:latest', |
| 20 | + resourceLimitCpu: "2", |
| 21 | + resourceLimitMemory: "2048Mi", |
| 22 | + resourceRequestCpu: "100m", |
| 23 | + resourceRequestMemory: "1024Mi", |
| 24 | + ttyEnabled: true, |
| 25 | + command: 'cat' |
| 26 | + ), |
| 27 | + containerTemplate( |
| 28 | + name: 'semantic-release-poetry', |
| 29 | + image: 'us-docker.pkg.dev/tamr-docker/ops/semantic-release-poetry:latest', |
| 30 | + alwaysPullImage: false, |
| 31 | + ttyEnabled: true, |
| 32 | + command: 'cat' |
| 33 | + ), |
| 34 | + containerTemplate( |
| 35 | + name: 'jnlp', |
| 36 | + image: 'us-docker.pkg.dev/tamr-docker/ops/jenkins-agent:latest', |
| 37 | + alwaysPullImage: false, |
| 38 | + privileged: false, |
| 39 | + // Resources for jnlp container |
| 40 | + resourceLimitCpu: "2", |
| 41 | + resourceLimitMemory: "1Gi", |
| 42 | + resourceRequestCpu: "300m", |
| 43 | + resourceRequestMemory: "1Gi" |
| 44 | + ), |
| 45 | + ], |
| 46 | + serviceAccount: "jenkins-emaas", |
| 47 | + annotations: [ |
| 48 | + podAnnotation( key: "iam.gke.io/gcp-service-account", value: "[email protected]") |
| 49 | + ] |
| 50 | +) { |
| 51 | + node(POD_LABEL) { |
| 52 | + helper.cancelPreviousBuilds() |
| 53 | + |
| 54 | + def projectName = helper.getProjectName().tokenize('/').last() |
| 55 | + def projectRepo = scm.userRemoteConfigs.first().url - '.git' |
| 56 | + |
| 57 | + stage('Checkout') { |
| 58 | + echo projectName |
| 59 | + echo projectRepo |
| 60 | + checkout([ |
| 61 | + $class : 'GitSCM', |
| 62 | + branches : scm.branches, |
| 63 | + extensions : scm.extensions + [[$class: 'CloneOption', noTags: false]], |
| 64 | + userRemoteConfigs: scm.userRemoteConfigs |
| 65 | + ]) |
| 66 | + sh 'pwd' |
| 67 | + sh 'id' |
| 68 | + sh 'export' |
| 69 | + sh 'ls -l .' |
| 70 | + } |
| 71 | + try { |
| 72 | + container('python-poetry-with-java-8') { |
| 73 | + |
| 74 | + stage('Build tamr_sdk') { |
| 75 | + timeout(time: 10, unit: 'MINUTES') { |
| 76 | + { |
| 77 | + sh """ |
| 78 | + poetry build |
| 79 | + """ |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + container("semantic-release-poetry") { |
| 86 | + stage('Lint Commits') { |
| 87 | + if (helper.isPRBuild()) { |
| 88 | + sh "./cicd/scripts/lint-commits.sh" |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + stage('Release') { |
| 94 | + if (currentBuild.result == null || currentBuild.result == 'SUCCESS') { |
| 95 | + container("semantic-release-poetry") { |
| 96 | + withCredentials([string(credentialsId: 'github-oauth', variable: 'GH_TOKEN')]) { |
| 97 | + withEnv(["GH_TOKEN=${GH_TOKEN}"]) { |
| 98 | + sh "semantic-release --dry-run" |
| 99 | + } |
| 100 | + if (helper.getBranchName() == 'main' && !helper.isPRBuild()) { |
| 101 | + withEnv(["GH_TOKEN=${GH_TOKEN}"]) { |
| 102 | + sh "poetry config repositories.artifact-registry" |
| 103 | + sh "semantic-release" |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | +} |
0 commit comments