This repository was archived by the owner on Oct 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Support windows for gsutil #985
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1e5160a
Support windows for gsutil
v1v 8436bea
Not anymore in master but always
v1v 921ed11
Add for testing purposes
v1v 0dae25a
For testing purposes
v1v eeeff67
Support windows
v1v 880ec98
update README docs
v1v b21fae4
Use the right worker label
v1v c53dd4b
Use interpolation otherwise windows seems to fail
v1v fc5c993
Revert "Use interpolation otherwise windows seems to fail"
v1v b5b584a
Support credentials in windows without interpolation
v1v 225d1b7
Only for the master branch and reduce the number of files to be stored
v1v 916fb2e
Add more pipeline validations
v1v 70e2693
Revert "For testing purposes"
v1v File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,13 +117,25 @@ pipeline { | |
| } | ||
| } | ||
| stage('Google Storage') { | ||
| steps { | ||
| withGithubNotify(context: 'Google Storage', description: 'Google Storage step') { | ||
| dir("${BASE_DIR}"){ | ||
| googleStorageUploadExt(bucket: "gs://${env.JOB_GCS_BUCKET}/${env.REPO}/commits/${env.GIT_BASE_COMMIT}", pattern: 'src/**/*.gdsl', sharedPublicly: false) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| stage('Google Storage Windows') { | ||
| agent { label 'windows-2019-immutable' } | ||
| when { | ||
| branch 'master' // TODO: to be removed as soon as the step is available in the master branch | ||
| branch 'master' | ||
| } | ||
| steps { | ||
| withGithubNotify(context: 'Google Storage', description: 'Google Storage step') { | ||
| withGithubNotify(context: 'Google Storage Windows', description: 'Google Storage step') { | ||
| deleteDir() | ||
| unstash 'source' | ||
| dir("${BASE_DIR}"){ | ||
| googleStorageUploadExt(bucket: "gs://${env.JOB_GCS_BUCKET}/${env.REPO}/commits/${env.GIT_BASE_COMMIT}", pattern: 'target/**/*.xml', sharedPublicly: false) | ||
| googleStorageUploadExt(bucket: "gs://${env.JOB_GCS_BUCKET}/${env.REPO}/commits/${env.GIT_BASE_COMMIT}", pattern: 'resources/**/*.json', sharedPublicly: false) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -135,9 +147,15 @@ pipeline { | |
| validateDeclarativePipeline '.ci/Jenkinsfile' | ||
| validateDeclarativePipeline '.ci/buildBeatsDockerImages.groovy' | ||
| validateDeclarativePipeline '.ci/buildDockerImages.groovy' | ||
| validateDeclarativePipeline '.ci/chatops.groovy' | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated |
||
| validateDeclarativePipeline '.ci/buildDockerImages.groovy' | ||
| validateDeclarativePipeline '.ci/dockerImagesOpbeans.groovy' | ||
| validateDeclarativePipeline '.ci/jobdsl-generator.groovy' | ||
| validateDeclarativePipeline '.ci/licenseScan.groovy' | ||
| validateDeclarativePipeline '.ci/licenseScanGeneral.groovy' | ||
| validateDeclarativePipeline '.ci/schedule-daily.groovy' | ||
| validateDeclarativePipeline '.ci/schedule-weekly.groovy' | ||
| validateDeclarativePipeline '.ci/validateWorkersBeatsCi.groovy' | ||
| validateDeclarativePipeline 'resources/JenkinsfileTemplate.groovy' | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,6 @@ import groovy.transform.Field | |
| @Field def gsUtilLocation = '' | ||
|
|
||
| def call(Map args = [:]) { | ||
| if(!isUnix()) { | ||
| error 'gsutil: windows is not supported yet.' | ||
| } | ||
| def command = args.containsKey('command') ? args.command : error('gsutil: command argument is required.') | ||
| def credentialsId = args.containsKey('credentialsId') ? args.credentialsId : error('gsutil: credentialsId argument is required.') | ||
|
|
||
|
|
@@ -38,25 +35,40 @@ def call(Map args = [:]) { | |
| downloadInstaller(gsUtilLocation) | ||
| } | ||
|
|
||
| withCredentials([file(credentialsId: credentialsId, variable: 'FILE_CREDENTIAL')]) { | ||
| sh(label: 'authenticate', script: 'gcloud auth activate-service-account --key-file ${FILE_CREDENTIAL}') | ||
| withCredentials([file(credentialsId: credentialsId, variable: 'FILE_CREDENTIAL')]) { | ||
| def credentialsVariable = isUnix() ? '${FILE_CREDENTIAL}' : '%FILE_CREDENTIAL%' | ||
| cmd(label: 'authenticate', script: 'gcloud auth activate-service-account --key-file ' + credentialsVariable) | ||
|
Comment on lines
+39
to
+40
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid interpolation for any kind of credentials |
||
| } | ||
| return sh(label: "gsutil ${command}", script: "gsutil ${command}", returnStdout: true) | ||
| return cmd(label: "gsutil ${command}", script: "gsutil ${command}", returnStdout: true) | ||
| } | ||
| } | ||
|
|
||
| def downloadInstaller(where) { | ||
| def url = 'https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-319.0.0' | ||
| url = "${url}-linux-${is64() ? 'x86_64' : 'x86'}.tar.gz" | ||
| def tarball = 'gsutil.tar.gz' | ||
| def url = googleCloudSdkURL() | ||
| def tarball = "gsutil.${isUnix() ? 'tar.gz' : 'zip'}" | ||
| if(isInstalled(tool: 'wget', flag: '--version')) { | ||
| dir(where) { | ||
| retryWithSleep(retries: 3, seconds: 5, backoff: true) { | ||
| sh(label: 'download gsutil', script: "wget -q -O ${tarball} ${url}") | ||
| sh(label: 'untar gsutil', script: "tar -xpf ${tarball} --strip-components=1") | ||
| cmd(label: 'download gsutil', script: "wget -q -O ${tarball} ${url}") | ||
| uncompress(tarball) | ||
| } | ||
| } | ||
| } else { | ||
| log(level: 'WARN', text: 'gsutil: wget is not available. gsutil will not be installed then.') | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def googleCloudSdkURL() { | ||
| def url = 'https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-319.0.0' | ||
| def os = isUnix() ? 'linux' : 'windows' | ||
| def ext = isUnix() ? 'tar.gz' : 'zip' | ||
| return "${url}-${os}-${is64() ? 'x86_64' : 'x86'}.${ext}" | ||
| } | ||
|
|
||
| def uncompress(tarball) { | ||
| if (isUnix()) { | ||
| sh(label: 'untar gsutil', script: "tar -xpf ${tarball} --strip-components=1") | ||
| } else { | ||
| unzip(quiet: true, zipFile: tarball) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run always