jenkinsutil 1.0.64 → 1.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -2
- data/JenkinsUtil.gemspec +1 -1
- data/README.md +2 -0
- data/certs/cacert.pem +4043 -0
- data/jenkins/test.groovy +54 -62
- data/lib/jenkins_util/dropbox_util.rb +33 -19
- metadata +6 -11
data/jenkins/test.groovy
CHANGED
@@ -1,64 +1,56 @@
|
|
1
1
|
#!groovy
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
'
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
bat 'call bundle exec rake ci:setup:testunit test:default build'
|
58
|
-
|
59
|
-
step([$class: 'JUnitResultArchiver', testResults: 'test/reports/**/*.xml'])
|
60
|
-
//step([$class: 'RcovPublisher', reportDir: 'coverage/rcov/'])
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
)
|
3
|
+
stage('linux test') {
|
4
|
+
node('docker') {
|
5
|
+
checkout scm
|
6
|
+
|
7
|
+
def dockerRepository = "${env.JOB_NAME}".toLowerCase()
|
8
|
+
def dockerTag = "${dockerRepository}:${env.BUILD_NUMBER}"
|
9
|
+
def dockerContainerName = "${dockerRepository}_${env.BUILD_NUMBER}"
|
10
|
+
|
11
|
+
sh """docker build \
|
12
|
+
-t ${dockerTag} \
|
13
|
+
."""
|
14
|
+
|
15
|
+
sh """docker run \
|
16
|
+
-e BUILD_NUMBER=${env.BUILD_NUMBER} \
|
17
|
+
-e DROPBOX_ACCESS_TOKEN=${env.DROPBOX_ACCESS_TOKEN} \
|
18
|
+
--name ${dockerContainerName} \
|
19
|
+
${dockerTag}"""
|
20
|
+
|
21
|
+
sh "docker cp ${dockerContainerName}:/artifacts ${env.WORKSPACE}"
|
22
|
+
sh "docker stop ${dockerContainerName}"
|
23
|
+
|
24
|
+
step([$class: 'JUnitResultArchiver', testResults: 'artifacts/**/*.xml'])
|
25
|
+
//step([$class: 'RcovPublisher', reportDir: 'artifacts/coverage/rcov/'])
|
26
|
+
}
|
27
|
+
}
|
28
|
+
stage('osx test') {
|
29
|
+
node('ruby-osx') {
|
30
|
+
checkout scm
|
31
|
+
|
32
|
+
sh "bundle install --path='./gems/'"
|
33
|
+
|
34
|
+
sh """DROPBOX_ACCESS_TOKEN=${env.DROPBOX_ACCESS_TOKEN} \
|
35
|
+
RUBYOPT='-W0' \
|
36
|
+
CI_CAPTURE=off \
|
37
|
+
bundle exec \
|
38
|
+
rake ci:setup:testunit \
|
39
|
+
test:all \
|
40
|
+
build"""
|
41
|
+
|
42
|
+
step([$class: 'JUnitResultArchiver', testResults: 'test/reports/**/*.xml'])
|
43
|
+
}
|
44
|
+
}
|
45
|
+
stage('windows test') {
|
46
|
+
node('ruby-windows') {
|
47
|
+
checkout scm
|
48
|
+
|
49
|
+
bat 'call bundle install --path=./gems'
|
50
|
+
bat 'set DROPBOX_ACCESS_TOKEN=${env.DROPBOX_ACCESS_TOKEN}'
|
51
|
+
bat 'call bundle exec rake SSL_CERT_FILE=%cd%\\certs\\cacert.pem ci:setup:testunit test:default build'
|
52
|
+
|
53
|
+
step([$class: 'JUnitResultArchiver', testResults: 'test/reports/**/*.xml'])
|
54
|
+
//step([$class: 'RcovPublisher', reportDir: 'coverage/rcov/'])
|
55
|
+
}
|
56
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'dropbox_api'
|
2
2
|
require 'jenkins_util/logger_util'
|
3
3
|
require 'jenkins_util/version'
|
4
4
|
require 'pathname'
|
@@ -14,7 +14,7 @@ module DropboxUtil
|
|
14
14
|
LoggerUtil.fatal('Root must be passed if flatten is false') if !flatten && root.nil?
|
15
15
|
LoggerUtil.fatal('Please set environment variable DROPBOX_ACCESS_TOKEN') if ENV['DROPBOX_ACCESS_TOKEN'].nil?
|
16
16
|
|
17
|
-
@dropbox_client ||=
|
17
|
+
@dropbox_client ||= DropboxApi::Client.new(ENV['DROPBOX_ACCESS_TOKEN'])
|
18
18
|
@sources = sources
|
19
19
|
@destination = destination
|
20
20
|
@flatten = flatten
|
@@ -23,14 +23,12 @@ module DropboxUtil
|
|
23
23
|
upload_files
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.delete(
|
27
|
-
@dropbox_client
|
28
|
-
|
29
|
-
LoggerUtil.fatal('Location passed is nil') if dropbox_location.nil?
|
26
|
+
def self.delete(file_path)
|
27
|
+
retrier(file_path) { @dropbox_client.delete(file_path) } unless @dropbox_client.nil?
|
30
28
|
end
|
31
29
|
|
32
30
|
def self.upload_files
|
33
|
-
LoggerUtil.log.debug(@dropbox_client.
|
31
|
+
LoggerUtil.log.debug(@dropbox_client.get_current_account.inspect) # Check auth
|
34
32
|
@sources = [@sources] unless @sources.respond_to?('each')
|
35
33
|
|
36
34
|
@sources.each do |source|
|
@@ -40,7 +38,7 @@ module DropboxUtil
|
|
40
38
|
upload_and_share(file)
|
41
39
|
end
|
42
40
|
end
|
43
|
-
rescue
|
41
|
+
rescue DropboxApi::Errors::UploadError
|
44
42
|
LoggerUtil.fatal('User is not authenticated, please verify access token')
|
45
43
|
end
|
46
44
|
|
@@ -65,27 +63,43 @@ module DropboxUtil
|
|
65
63
|
return if File.directory?(file)
|
66
64
|
|
67
65
|
@uploaded_files ||= []
|
66
|
+
retrier(file) do
|
67
|
+
dropbox_file = @dropbox_client.upload(dropbox_file_destination(file), IO.read(file))
|
68
|
+
LoggerUtil.log.debug("Successfully uploaded #{file}")
|
68
69
|
|
69
|
-
|
70
|
+
@dropbox_client.share_folder(@destination)
|
71
|
+
temp_link = @dropbox_client.get_temporary_link(dropbox_file.path_display)
|
72
|
+
|
73
|
+
LoggerUtil.log.info("path: #{dropbox_file.path_display}")
|
74
|
+
LoggerUtil.log.info("url: #{temp_link.link}")
|
75
|
+
end
|
76
|
+
end
|
70
77
|
|
78
|
+
def self.download(file_path)
|
79
|
+
retrier(file_path) { @dropbox_client.download(file_path) }
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.retrier(file)
|
83
|
+
retries = 0
|
71
84
|
begin
|
72
|
-
|
73
|
-
|
74
|
-
rescue DropboxError => e
|
85
|
+
response = yield
|
86
|
+
rescue DropboxApi::Errors::BasicError, DropboxApi::Errors::HttpError => e
|
75
87
|
retries += 1
|
76
|
-
if retries
|
77
|
-
|
88
|
+
if retries <= 5
|
89
|
+
# Rate Limit and Namespace Lock Contentions introduced in v2 APIs
|
90
|
+
# https://www.dropbox.com/developers/reference/data-ingress-guide
|
91
|
+
delay = e.is_a?(DropboxApi::Errors::TooManyWriteOperationsError) ? e.retry_after * retries : retries
|
92
|
+
sleep(delay)
|
93
|
+
LoggerUtil.log.debug("Attempt #{retries} failed. Retrying #{file} after #{delay} seconds")
|
94
|
+
|
78
95
|
retry
|
79
96
|
end
|
80
97
|
|
81
|
-
LoggerUtil.
|
98
|
+
LoggerUtil.fatal("Exceeded maximum retries. Failed to #{caller_locations[0].label} #{file}")
|
82
99
|
raise e
|
83
100
|
end
|
84
101
|
|
85
|
-
|
86
|
-
|
87
|
-
LoggerUtil.log.info("path: #{dropbox_file['path']}")
|
88
|
-
LoggerUtil.log.info("url: #{share['url']}")
|
102
|
+
response unless response.nil?
|
89
103
|
end
|
90
104
|
|
91
105
|
private_class_method :upload_files, :dropbox_file_destination, :upload_and_share
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jenkinsutil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.65
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett McGinnis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open4
|
@@ -51,25 +51,19 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 1.1.3
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: dropbox_api
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
-
- - '='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 1.6.5
|
59
|
+
version: 0.1.5
|
63
60
|
type: :runtime
|
64
61
|
prerelease: false
|
65
62
|
version_requirements: !ruby/object:Gem::Requirement
|
66
63
|
requirements:
|
67
64
|
- - "~>"
|
68
65
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
70
|
-
- - '='
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 1.6.5
|
66
|
+
version: 0.1.5
|
73
67
|
- !ruby/object:Gem::Dependency
|
74
68
|
name: xcodeproj
|
75
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -373,6 +367,7 @@ files:
|
|
373
367
|
- Rakefile
|
374
368
|
- bin/console
|
375
369
|
- bin/setup
|
370
|
+
- certs/cacert.pem
|
376
371
|
- exe/jenkinsutil
|
377
372
|
- jenkins/deploy.Jenkinsfile
|
378
373
|
- jenkins/deploy.groovy
|