-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add -tail to job log #588
add -tail to job log #588
Conversation
Welcome @jxr98! It looks like this is your first PR to jenkins-zh/jenkins-cli 🎉 |
Codecov Report
@@ Coverage Diff @@
## master #588 +/- ##
=======================================
Coverage 38.46% 38.46%
=======================================
Files 13 13
Lines 286 286
=======================================
Hits 110 110
Misses 164 164
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
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.
Thanks for your contribution. The calculation seems wrong. Please take a look at it.
➜ jenkins-cli git:(tail) ✗ ./jcli job log test -t 2
Current build number: 1
Current build url: http://139.198.3.176:30180/job/test/1/
Finished: SUCCESS
➜ jenkins-cli git:(tail) ✗ ./jcli job log test -t 3
Current build number: 1
Current build url: http://139.198.3.176:30180/job/test/1/
[Pipeline] End of Pipeline
Finished: SUCCESS
Please make sure that you have executed the command: make fmt
before you submit.
app/cmd/job_log.go
Outdated
@@ -34,6 +34,8 @@ func init() { | |||
i18n.T("Watch the job logs")) | |||
jobLogCmd.Flags().IntVarP(&jobLogOption.Interval, "interval", "i", 1, | |||
i18n.T("Interval of watch")) | |||
jobLogCmd.Flags().IntVarP(&jobLogOption.NumberOfLines,"tail","t",-1, | |||
i18n.T("the last number of lines of the log")) |
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.
The first letter should be capital.
app/cmd/job_log.go
Outdated
numberOfLinesStr :=args[2] | ||
numberOfLines, err:=strconv.Atoi(numberOfLinesStr) | ||
if err!=nil||numberOfLines<=0 { | ||
err =fmt.Errorf(err.Error(),"lines of job must be a positive integer instead of '%s'",numberOfLinesStr) | ||
}else{ | ||
jobLogOption.NumberOfLines=numberOfLines | ||
} |
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.
It's not necessary to parse the value of tail
. The following code can do that.
jobLogCmd.Flags().IntVarP(&jobLogOption.NumberOfLines,"tail","t",-1, i18n.T("the last number of lines of the log"))
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.
All righty. I've changed that. The lines of 'Current build number' and 'Current build url' are not counted in the 'tail number', but there was a bug about the number of lines to be printed and it has been fixed. Thx.
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.
It works well. Thanks!
➜ jenkins-cli git:(tail) jcli job log test -t 7
Current build number: 1
Current build url: http://139.198.3.176:30180/job/test/1/
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
You're welcome. Thx for reviewing my code. |
Make sure that you've checked the boxes below before you submit PR:
Always
For the bug fixes or features only