Skip to content

Commit

Permalink
Prepare Azure CI pipeline for OAuth (#224)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Scholz <www@scholzj.com>
  • Loading branch information
scholzj authored Feb 6, 2024
1 parent 80cca5d commit e108c65
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 30 deletions.
29 changes: 29 additions & 0 deletions .azure/build-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -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: ''
16 changes: 16 additions & 0 deletions .azure/scripts/push-to-nexus.sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
60 changes: 60 additions & 0 deletions .azure/templates/jobs/build_java.yaml
Original file line number Diff line number Diff line change
@@ -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()
43 changes: 43 additions & 0 deletions .azure/templates/jobs/deploy_java.yaml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions .azure/templates/steps/maven_cache.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions .azure/templates/steps/prerequisites/install_java.yaml
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@ env:
- PULL_REQUEST=${TRAVIS_PULL_REQUEST}
- TAG=${TRAVIS_TAG:-latest}
- BRANCH=${TRAVIS_BRANCH:-main}
- secure: ZUtBG8nQ3n7r434wrNnkSSMwpqG8Bdqv/nUubP7RPAtGIS/qyWOtYsNLyAj1jKpS5NR0xuqMBSX6BJd8JbG11gpTYH4Gx4aE+TmnhFm489IgywLe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VArZ9Hf2GsN2lifMrqXZVPZAuHEiHTjC+vr8JEmfAQ/ZnzxqjggUZ1DiJPs2LEmc0Fe6tH44YLw7mBBuTJb/TpbLZlmA8aq2YQ8T+9XfqkGshJkG4ZY578g6aN64EwE3JQk4PyfcyqeBJ6WkSRD/SF3E2G9FQtAh8DFq51uxPyu3F88i72WqTGq8BiaSXtvVnzHPWhNci0=
- 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"
15 changes: 0 additions & 15 deletions .travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions .travis/push-to-nexus.sh

This file was deleted.

Binary file removed .travis/signing.gpg.enc
Binary file not shown.

0 comments on commit e108c65

Please sign in to comment.