From e108c65e68646439b330447d9f7b3aa757144989 Mon Sep 17 00:00:00 2001 From: Jakub Scholz Date: Tue, 6 Feb 2024 20:12:46 +0100 Subject: [PATCH] Prepare Azure CI pipeline for OAuth (#224) Signed-off-by: Jakub Scholz --- .azure/build-pipeline.yaml | 29 +++++++++ .azure/scripts/push-to-nexus.sh | 16 +++++ {.travis => .azure/scripts}/settings.xml | 0 .azure/templates/jobs/build_java.yaml | 60 ++++++++++++++++++ .azure/templates/jobs/deploy_java.yaml | 43 +++++++++++++ .azure/templates/steps/maven_cache.yaml | 9 +++ .../steps/prerequisites/install_java.yaml | 11 ++++ .travis.yml | 3 - .travis/build.sh | 15 ----- .travis/push-to-nexus.sh | 12 ---- .travis/signing.gpg.enc | Bin 2656 -> 0 bytes 11 files changed, 168 insertions(+), 30 deletions(-) create mode 100644 .azure/build-pipeline.yaml create mode 100755 .azure/scripts/push-to-nexus.sh rename {.travis => .azure/scripts}/settings.xml (100%) create mode 100644 .azure/templates/jobs/build_java.yaml create mode 100644 .azure/templates/jobs/deploy_java.yaml create mode 100644 .azure/templates/steps/maven_cache.yaml create mode 100644 .azure/templates/steps/prerequisites/install_java.yaml delete mode 100755 .travis/push-to-nexus.sh delete mode 100644 .travis/signing.gpg.enc diff --git a/.azure/build-pipeline.yaml b/.azure/build-pipeline.yaml new file mode 100644 index 00000000..46bbb875 --- /dev/null +++ b/.azure/build-pipeline.yaml @@ -0,0 +1,29 @@ +# Triggers +trigger: + branches: + include: + - 'main' + - 'release-*' +pr: + autoCancel: true + branches: + include: + - '*' + +# Stages +stages: + - stage: java_build + displayName: Java build + jobs: + - template: 'templates/jobs/build_java.yaml' + - stage: java_deploy + displayName: Deploy Java + condition: and(succeeded(), or(eq(variables['build.sourceBranch'], 'refs/heads/main'), startsWith(variables['build.sourceBranch'], 'refs/heads/release-'))) + jobs: + - template: 'templates/jobs/deploy_java.yaml' + parameters: + artifactSource: 'current' + artifactProject: 'strimzi' + artifactPipeline: '' + artifactRunVersion: '' + artifactRunId: '' diff --git a/.azure/scripts/push-to-nexus.sh b/.azure/scripts/push-to-nexus.sh new file mode 100755 index 00000000..2c6cced8 --- /dev/null +++ b/.azure/scripts/push-to-nexus.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +echo "Build reason: ${BUILD_REASON}" +echo "Source branch: ${BRANCH}" + +GPG_TTY=$(tty) +export GPG_TTY + +echo "$GPG_SIGNING_KEY" | base64 -d > signing.gpg +gpg --batch --import signing.gpg + +GPG_EXECUTABLE=gpg mvn $MVN_ARGS -DskipTests -s ./.azure/scripts/settings.xml -pl '!examples/producer','!examples/consumer' -P ossrh verify deploy + +rm -rf signing.gpg +gpg --delete-keys +gpg --delete-secret-keys \ No newline at end of file diff --git a/.travis/settings.xml b/.azure/scripts/settings.xml similarity index 100% rename from .travis/settings.xml rename to .azure/scripts/settings.xml diff --git a/.azure/templates/jobs/build_java.yaml b/.azure/templates/jobs/build_java.yaml new file mode 100644 index 00000000..508647d9 --- /dev/null +++ b/.azure/templates/jobs/build_java.yaml @@ -0,0 +1,60 @@ +jobs: + - job: 'build_and_test_java' + displayName: 'Build & Test' + # Strategy for the job + strategy: + matrix: + 'java-8': + image: 'Ubuntu-22.04' + jdk_version: '8' + main_build: 'true' + 'java-11': + image: 'Ubuntu-22.04' + jdk_version: '11' + main_build: 'false' + 'java-17': + image: 'Ubuntu-22.04' + jdk_version: '17' + main_build: 'false' + # Set timeout for jobs + timeoutInMinutes: 60 + # Base system + pool: + vmImage: $(image) + # Variables + variables: + MVN_CACHE_FOLDER: $(HOME)/.m2/repository + MVN_ARGS: '-e -V -B' + # Pipeline steps + steps: + # Get cached Maven repository + - template: "../steps/maven_cache.yaml" + - template: '../steps/prerequisites/install_java.yaml' + parameters: + JDK_VERSION: $(jdk_version) + - bash: "mvn ${MVN_ARGS} install" + displayName: "Build & Test Java" + env: + BUILD_REASON: $(Build.Reason) + BRANCH: $(Build.SourceBranch) + TESTCONTAINERS_RYUK_DISABLED: "TRUE" + TESTCONTAINERS_CHECKS_DISABLE: "TRUE" + MVN_ARGS: "-e -V -B" + - bash: "mvn ${MVN_ARGS} spotbugs:check" + displayName: "Spotbugs" + env: + MVN_ARGS: "-e -V -B" + # We have to TAR the target directory to maintain the permissions of + # the files which would otherwise change when downloading the artifact + - bash: tar -cvpf target.tar ./target + displayName: "Tar the target directory" + condition: and(succeeded(), eq(variables['main_build'], 'true')) + - publish: $(System.DefaultWorkingDirectory)/target.tar + artifact: Binary + condition: and(succeeded(), eq(variables['main_build'], 'true')) + - task: PublishTestResults@2 + inputs: + testResultsFormat: JUnit + testResultsFiles: '**/TEST-*.xml' + testRunTitle: "Unit & Integration tests" + condition: always() \ No newline at end of file diff --git a/.azure/templates/jobs/deploy_java.yaml b/.azure/templates/jobs/deploy_java.yaml new file mode 100644 index 00000000..040fde26 --- /dev/null +++ b/.azure/templates/jobs/deploy_java.yaml @@ -0,0 +1,43 @@ +jobs: + - job: 'deploy_java' + displayName: 'Deploy artifacts' + # Strategy for the job => we deploy the artifacts only from Java 11 + strategy: + matrix: + 'java-8': + image: 'Ubuntu-22.04' + jdk_version: '8' + main_build: 'true' + # Set timeout for jobs + timeoutInMinutes: 60 + # Base system + pool: + vmImage: 'Ubuntu-22.04' + # Pipeline steps + steps: + # Get cached Maven repository + - template: "../steps/maven_cache.yaml" + - template: '../steps/prerequisites/install_java.yaml' + parameters: + JDK_VERSION: $(jdk_version) + - task: DownloadPipelineArtifact@2 + inputs: + source: '${{ parameters.artifactSource }}' + artifact: Binary + path: $(System.DefaultWorkingDirectory)/ + project: '${{ parameters.artifactProject }}' + pipeline: '${{ parameters.artifactPipeline }}' + runVersion: '${{ parameters.artifactRunVersion }}' + runId: '${{ parameters.artifactRunId }}' + - bash: tar -xvf target.tar + displayName: "Untar the target directory" + - bash: "./.azure/scripts/push-to-nexus.sh" + env: + BUILD_REASON: $(Build.Reason) + BRANCH: $(Build.SourceBranch) + GPG_PASSPHRASE: $(GPG_PASSPHRASE) + GPG_SIGNING_KEY: $(GPG_SIGNING_KEY) + NEXUS_USERNAME: $(NEXUS_USERNAME) + NEXUS_PASSWORD: $(NEXUS_PASSWORD) + MVN_ARGS: "-e -V -B" + displayName: "Deploy Java artifacts" \ No newline at end of file diff --git a/.azure/templates/steps/maven_cache.yaml b/.azure/templates/steps/maven_cache.yaml new file mode 100644 index 00000000..4dc3b774 --- /dev/null +++ b/.azure/templates/steps/maven_cache.yaml @@ -0,0 +1,9 @@ +steps: + - task: Cache@2 + inputs: + key: 'maven-cache | $(System.JobName) | **/pom.xml' + restoreKeys: | + maven-cache | $(System.JobName) + maven-cache + path: $(HOME)/.m2/repository + displayName: Maven cache diff --git a/.azure/templates/steps/prerequisites/install_java.yaml b/.azure/templates/steps/prerequisites/install_java.yaml new file mode 100644 index 00000000..fad0b09b --- /dev/null +++ b/.azure/templates/steps/prerequisites/install_java.yaml @@ -0,0 +1,11 @@ +# Step to configure JAVA on the agent +parameters: + - name: JDK_VERSION + default: '11' +steps: + - task: JavaToolInstaller@0 + inputs: + versionSpec: $(JDK_VERSION) + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + displayName: 'Configure Java' diff --git a/.travis.yml b/.travis.yml index a3c3b7c8..1764383a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,8 +51,5 @@ env: - PULL_REQUEST=${TRAVIS_PULL_REQUEST} - TAG=${TRAVIS_TAG:-latest} - BRANCH=${TRAVIS_BRANCH:-main} - - secure: ZUtBG8nQ3n7r434wrNnkSSMwpqG8Bdqv/nUubP7RPAtGIS/qyWOtYsNLyAj1jKpS5NR0xuqMBSX6BJd8JbG11gpTYH4Gx4aE+TmnhFm489IgywLeEKrlU+5m26I4kMw/P/JoK1jJ6Juu9TyLMLtzkzJhYK1n/VVS1kq2LRXn81ukJrhbxGIqNvk6ok46s0L8SWwjFVyBPgzxc6kcjOQSn9y/zrKsSZUVi6dW0Q7oGTfIMq6LIIlQWk3LJPMW4g8QH6+67WI4z9Ef8z5lzcJ5ypi0tD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u3F88i72WqTGq8BiaSXtvVnzHPWhNci0= - - secure: jRSKNwKeuq2wRif3UMcq/3V5qnCBLQB9TwyvFUGAs8eYqE83WnOcNqss2psTlY7JOHJUnNrXUvXLwp4bxlhkLqI7bUtRt96bPlZfCXKPUV95y8QMqahH6mMQARzFGhNjsU11ofYQROYoIg8I/IHMvsbQLTaf00D1d3PKqzRP+U9N/Mg8VlbzX45oSAsx7kC3KtTIVZQ1vwxt2wC9JViyDgJBHakH/tpvAbpkbMROQiIEXPY8G7P+6F1Cz4ipEltwIpZPDcRMb09/gAF1qnWIl1Xc3BLQnE+H/fA7nYF6bKwoMwISM3/DwU7n1ola7GWJ+nbuiisMrT1+gBTeQg0UG0mN8ILIyNlhOb3gd+5FvIyXWrXWN0PEonuTRlcYy3Tz7OiGadjQDuHLqH8uoqnZzSHF4Hii6lndkCK8Vrosi8aj42xcahE5MS+KrI7ji5xF2ILajEBcSHWWV3aIfz4zEzI/g+7FgKpTxViru5zw6Jdp+kijN9cMl6rhIKumfhyRzqf9apSTlVCKlc64FqfW6yCz+oVcBFmyLMT+hAWBGaj6qpFIEDEtx8wSfzhMGJCvsqHxNpM02g6WKI9GVGsp9y85sJ6mu/qkmZgw6bINU/pSp1oHquBmfl5OOkjuqOloOtFQMZUVQYBTSCK87DlYKKmCOtvUxeRMsrlbQLR9g2k= # GPG_PASSPHRASE script: - "./.travis/build.sh" diff --git a/.travis/build.sh b/.travis/build.sh index 7899bffc..3fc80b21 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -99,18 +99,3 @@ if [ "$arch" != 'ppc64le' ] && [ "$arch" != 's390x' ]; then set -e fi - - -# Only continue if Java 8 and x86_64 platform -if [ "$JAVA_MAJOR_VERSION" == "1" ] && [ "$arch" == "x86_64" ]; then - - # Push only releases - if [ "$PULL_REQUEST" != "false" ] ; then - echo "Building Pull Request - nothing to push" - elif [ "$TAG" = "latest" ] && [ "$BRANCH" != "main" ]; then - echo "Not in main branch and not in release tag - nothing to push" - else - echo "Pushing JARs" - ./.travis/push-to-nexus.sh - fi -fi diff --git a/.travis/push-to-nexus.sh b/.travis/push-to-nexus.sh deleted file mode 100755 index 7be78bc3..00000000 --- a/.travis/push-to-nexus.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -export GPG_TTY=$(tty) - -openssl aes-256-cbc -K $encrypted_a40d2cfb3073_key -iv $encrypted_a40d2cfb3073_iv -in .travis/signing.gpg.enc -out signing.gpg -d -gpg --batch --import signing.gpg - -GPG_EXECUTABLE=gpg mvn -B -DskipTests -s ./.travis/settings.xml -pl '!examples/producer','!examples/consumer' -P ossrh clean verify deploy - -rm -rf signing.gpg -gpg --delete-keys -gpg --delete-secret-keys \ No newline at end of file diff --git a/.travis/signing.gpg.enc b/.travis/signing.gpg.enc deleted file mode 100644 index b44beee46046ac62f110d04fd9f2faaddab36342..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2656 zcmV-m3ZL~CQ>&=tn{06?DT;xdom0JLo4eY9f>S#LeXZQD2eDfaQ#N1vigkN$v~*G? ze=X@RX#$~BbH!sXo8^D#BAD;(C&ssidARVcm?ZyaK=}s{j4jU3BgCL6mzpn}E2SOn zq;YG;VoD^{``gCu=Ew(JN!>P6@{S;;<^}ga^7pA*(PzG>bY0!CJXqN_$zne1DX;nu z@$zAt6~M3Rs{8*LLRn>5%s0?N?)whgLPb?+Pi@%k_Pd!U7D!231J~3RP8G(RIKb@R zC%K{vV0~^Ot088w=VNMfSMrivsIL1Qv%pAWEfx1=LQ^ul`E+6ix=x2582!_sJ@&g8 zW480!VHAQ7??Ghknhk-|gyY;yQ%8NeRz0G=3WFLK&nzPCo zl|^O)7Wn0v{l+5MxNZB4Q*Q6O6gI579%^Te?EvD`aYGirWGWKgZY=+7i4+A+dj+GSD8RI&HR+~%|y5TGEng|{r6xl3`(%wwQGiv8U zF!P#e02HSATRx)(6hl+HOY-e%Ia&@A6i7B~-(kV|7mbqo9 zR>o+sEm88@n5fv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