Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aliyun-oss-uploader
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tools
aliyun-oss-uploader
Commits
36595791
Commit
36595791
authored
Jun 07, 2019
by
raylax
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issues
parent
07478cc6
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
15 deletions
+32
-15
README.md
README.md
+1
-1
pom.xml
pom.xml
+1
-1
src/main/java/org/inurl/jenkins/plugin/OSSPublisher.java
src/main/java/org/inurl/jenkins/plugin/OSSPublisher.java
+20
-8
src/main/resources/index.jelly
src/main/resources/index.jelly
+0
-1
src/main/resources/org/inurl/jenkins/plugin/Messages.properties
...in/resources/org/inurl/jenkins/plugin/Messages.properties
+2
-1
src/main/resources/org/inurl/jenkins/plugin/Messages_zh.properties
...resources/org/inurl/jenkins/plugin/Messages_zh.properties
+2
-1
src/main/resources/org/inurl/jenkins/plugin/OSSPublisher/config.jelly
...ources/org/inurl/jenkins/plugin/OSSPublisher/config.jelly
+6
-2
No files found.
README.md
View file @
36595791
...
...
@@ -4,7 +4,7 @@
1.
下载hpi文件
[
aliyun-oss-
plugin
.hpi
](
https://github.com/raylax/jenkins-aliyun-oss-uploader/releases/latest
)
[
aliyun-oss-
uploader
.hpi
](
https://github.com/raylax/jenkins-aliyun-oss-uploader/releases/latest
)
2.
在plugins管理页面上传hpi文件并安装,重启jenkins
...
...
pom.xml
View file @
36595791
...
...
@@ -14,7 +14,7 @@
<properties>
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
<jenkins.version>
2.7.3
</jenkins.version>
<java.level>
7
</java.level>
<java.level>
8
</java.level>
<!-- Other properties you may want to use:
~ jenkins-test-harness.version: Jenkins Test Harness version you use to test the plugin. For Jenkins version >= 1.580.1 use JTH 2.0 or higher.
~ hpi-plugin.version: The HPI Maven Plugin version used by the plugin..
...
...
src/main/java/org/inurl/jenkins/plugin/OSSPublisher.java
View file @
36595791
...
...
@@ -11,10 +11,10 @@ import hudson.tasks.BuildStepDescriptor;
import
hudson.tasks.BuildStepMonitor
;
import
hudson.tasks.Publisher
;
import
hudson.util.FormValidation
;
import
hudson.util.Secret
;
import
jenkins.tasks.SimpleBuildStep
;
import
jnr.ffi.annotations.In
;
import
org.apache.commons.lang.StringUtils
;
import
org.
apache.commons.lang.math.NumberUtils
;
import
org.
jenkinsci.Symbol
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.QueryParameter
;
...
...
@@ -30,7 +30,7 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep {
private
final
String
accessKeyId
;
private
final
S
tring
accessKeySecret
;
private
final
S
ecret
accessKeySecret
;
private
final
String
bucketName
;
...
...
@@ -50,7 +50,7 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep {
}
public
String
getAccessKeySecret
()
{
return
accessKeySecret
;
return
accessKeySecret
.
getPlainText
()
;
}
public
String
getBucketName
()
{
...
...
@@ -73,7 +73,7 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep {
public
OSSPublisher
(
String
endpoint
,
String
accessKeyId
,
String
accessKeySecret
,
String
bucketName
,
String
localPath
,
String
remotePath
,
String
maxRetries
)
{
this
.
endpoint
=
endpoint
;
this
.
accessKeyId
=
accessKeyId
;
this
.
accessKeySecret
=
accessKeySecret
;
this
.
accessKeySecret
=
Secret
.
fromString
(
accessKeySecret
)
;
this
.
bucketName
=
bucketName
;
this
.
localPath
=
localPath
;
this
.
remotePath
=
remotePath
;
...
...
@@ -88,7 +88,7 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep {
@Override
public
void
perform
(
@Nonnull
Run
<?,
?>
run
,
@Nonnull
FilePath
workspace
,
@Nonnull
Launcher
launcher
,
@Nonnull
TaskListener
listener
)
throws
InterruptedException
,
IOException
{
PrintStream
logger
=
listener
.
getLogger
();
OSSClient
client
=
new
OSSClient
(
endpoint
,
accessKeyId
,
accessKeySecret
);
OSSClient
client
=
new
OSSClient
(
endpoint
,
accessKeyId
,
accessKeySecret
.
getPlainText
()
);
String
local
=
localPath
.
substring
(
1
);
String
remote
=
remotePath
.
substring
(
1
);
FilePath
p
=
new
FilePath
(
workspace
,
local
);
...
...
@@ -115,6 +115,10 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep {
}
private
void
uploadFile
(
OSSClient
client
,
PrintStream
logger
,
String
key
,
FilePath
path
)
throws
InterruptedException
,
IOException
{
if
(!
path
.
exists
())
{
logger
.
println
(
"file ["
+
path
.
getRemote
()
+
"] not exists, skipped"
);
return
;
}
int
maxRetries
=
getMaxRetries
();
int
retries
=
0
;
do
{
...
...
@@ -143,6 +147,7 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep {
client
.
putObject
(
bucketName
,
realKey
,
inputStream
);
}
@Symbol
(
"aliyunOSSUpload"
)
@Extension
public
static
final
class
DescriptorImpl
extends
BuildStepDescriptor
<
Publisher
>
{
...
...
@@ -173,11 +178,18 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep {
}
public
FormValidation
doCheckLocalPath
(
@QueryParameter
(
required
=
true
)
String
value
)
{
return
check
Value
(
value
,
Messages
.
OSSPublish_MissingLocalPath
()
);
return
check
BeginWithSlash
(
value
);
}
public
FormValidation
doCheckRemotePath
(
@QueryParameter
(
required
=
true
)
String
value
)
{
return
checkValue
(
value
,
Messages
.
OSSPublish_MissingRemotePath
());
return
checkBeginWithSlash
(
value
);
}
private
FormValidation
checkBeginWithSlash
(
String
value
)
{
if
(!
value
.
startsWith
(
"/"
))
{
return
FormValidation
.
error
(
Messages
.
OSSPublish_MustBeginWithSlash
());
}
return
FormValidation
.
ok
();
}
private
FormValidation
checkValue
(
String
value
,
String
message
)
{
...
...
src/main/resources/index.jelly
View file @
36595791
<?jelly escape-by-default='true'?>
<div>
TODO
</div>
src/main/resources/org/inurl/jenkins/plugin/Messages.properties
View file @
36595791
...
...
@@ -7,3 +7,4 @@ OSSPublish.MissingBucketName=Please set BucketName
OSSPublish.MissingLocalPath
=
Please set LocalPath
OSSPublish.MissingRemotePath
=
Please set RemotePath
OSSPublish.MaxRetiesMustBeNumbers
=
Must be number
OSSPublish.MustBeginWithSlash
=
Must begin with `/`
\ No newline at end of file
src/main/resources/org/inurl/jenkins/plugin/Messages_zh.properties
View file @
36595791
...
...
@@ -7,3 +7,4 @@ OSSPublish.MissingBucketName=\u8bf7\u8bbe\u7f6eBucketName
OSSPublish.MissingLocalPath
=
\u
8bf7
\u
8bbe
\u
7f6e
\u
672c
\u5730\u
8def
\u
5f84
OSSPublish.MissingRemotePath
=
\u
8bf7
\u
8bbe
\u
7f6e
\u
8fdc
\u
7a0b
\u
8def
\u
5f84
OSSPublish.MaxRetiesMustBeNumbers
=
\u6700\u5927\u
91cd
\u
8bd5
\u
6b21
\u6570\u
5fc5
\u
987b
\u
4e3a
\u6570\u
5b57
OSSPublish.MustBeginWithSlash
=
\u
5fc5
\u
987b
\u
4ee5`/`
\u
5f00
\u5934
\ No newline at end of file
src/main/resources/org/inurl/jenkins/plugin/OSSPublisher/config.jelly
View file @
36595791
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:jelly xmlns:j="jelly:core"
xmlns:st="jelly:stapler"
xmlns:d="jelly:define"
xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Endpoint}" field="endpoint">
<f:textbox />
</f:entry>
...
...
@@ -7,7 +11,7 @@
<f:textbox />
</f:entry>
<f:entry title="${%AccessKeySecret}" field="accessKeySecret">
<f:
textbox
/>
<f:
password
/>
</f:entry>
<f:entry title="${%BucketName}" field="bucketName">
<f:textbox />
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment