Skip to content

Commit

Permalink
[FLINK-16633][AZP] Fix builds without s3 credentials
Browse files Browse the repository at this point in the history
Problem: Builds on Azure where failing if S3 credentails were not provided, because the syntax in the pipeline definition was incorrect.

Solution: Use a way to access secret variables that leads to an empty value (instead of the variable name). Also, extend the check in the unit tests to "variable empty" instead of just "variable not set".
  • Loading branch information
rmetzger committed Mar 20, 2020
1 parent 0bc38ba commit b226cbd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
8 changes: 7 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ resources:
- container: flink-build-container
image: rmetzger/flink-ci:ubuntu-amd64-3528acd

# See tools/azure-pipelines/jobs-template.yml for a short summary of the caching
# Define variables:
# - See tools/azure-pipelines/jobs-template.yml for a short summary of the caching
# - See https://stackoverflow.com/questions/60742105/how-can-i-access-a-secret-value-from-an-azure-pipelines-expression
# to understand why the secrets are handled like this
variables:
MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository
MAVEN_OPTS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
CACHE_KEY: maven | $(Agent.OS) | **/pom.xml, !**/target/**
CACHE_FALLBACK_KEY: maven | $(Agent.OS)
CACHE_FLINK_DIR: $(Pipeline.Workspace)/flink_cache
SECRET_S3_BUCKET: $[variables.IT_CASE_S3_BUCKET]
SECRET_S3_ACCESS_KEY: $[variables.IT_CASE_S3_ACCESS_KEY]
SECRET_S3_SECRET_KEY: $[variables.IT_CASE_S3_SECRET_KEY]


jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ public class S3TestCredentials {
* Checks whether S3 test credentials are available in the environment variables
* of this JVM.
*/
public static boolean credentialsAvailable() {
return S3_TEST_BUCKET != null && S3_TEST_ACCESS_KEY != null && S3_TEST_SECRET_KEY != null;
private static boolean credentialsAvailable() {
return isNotEmpty(S3_TEST_BUCKET) && isNotEmpty(S3_TEST_ACCESS_KEY) && isNotEmpty(S3_TEST_SECRET_KEY);
}

/**
* Checks if a String is not null and not empty.
*/
private static boolean isNotEmpty(@Nullable String str) {
return str != null && !str.isEmpty();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions tools/azure-pipelines/build-apache-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ variables:
CACHE_KEY: maven | $(Agent.OS) | **/pom.xml, !**/target/**
CACHE_FALLBACK_KEY: maven | $(Agent.OS)
CACHE_FLINK_DIR: $(Pipeline.Workspace)/flink_cache
SECRET_S3_BUCKET: $[variables.IT_CASE_S3_BUCKET]
SECRET_S3_ACCESS_KEY: $[variables.IT_CASE_S3_ACCESS_KEY]
SECRET_S3_SECRET_KEY: $[variables.IT_CASE_S3_SECRET_KEY]

stages:
# CI / PR triggered stage:
Expand Down
12 changes: 6 additions & 6 deletions tools/azure-pipelines/jobs-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ jobs:
- script: STAGE=test ${{parameters.environment}} ./tools/azure_controller.sh $(module)
displayName: Test - $(module)
env:
IT_CASE_S3_BUCKET: $(IT_CASE_S3_BUCKET)
IT_CASE_S3_ACCESS_KEY: $(IT_CASE_S3_ACCESS_KEY)
IT_CASE_S3_SECRET_KEY: $(IT_CASE_S3_SECRET_KEY)
IT_CASE_S3_BUCKET: $(SECRET_S3_BUCKET)
IT_CASE_S3_ACCESS_KEY: $(SECRET_S3_ACCESS_KEY)
IT_CASE_S3_SECRET_KEY: $(SECRET_S3_SECRET_KEY)

- task: PublishTestResults@2
inputs:
Expand Down Expand Up @@ -175,9 +175,9 @@ jobs:
- script: ${{parameters.environment}} FLINK_DIR=`pwd`/build-target flink-end-to-end-tests/run-nightly-tests.sh
displayName: Run e2e tests
env:
IT_CASE_S3_BUCKET: $(IT_CASE_S3_BUCKET)
IT_CASE_S3_ACCESS_KEY: $(IT_CASE_S3_ACCESS_KEY)
IT_CASE_S3_SECRET_KEY: $(IT_CASE_S3_SECRET_KEY)
IT_CASE_S3_BUCKET: $(SECRET_S3_BUCKET)
IT_CASE_S3_ACCESS_KEY: $(SECRET_S3_ACCESS_KEY)
IT_CASE_S3_SECRET_KEY: $(SECRET_S3_SECRET_KEY)
# upload debug artifacts
- task: PublishPipelineArtifact@1
condition: and(succeededOrFailed(), not(eq('$(ARTIFACT_DIR)', '')))
Expand Down

0 comments on commit b226cbd

Please sign in to comment.