How to 'Discard old builds' without running job?

47 views
Skip to first unread message

David Aldrich

unread,
Apr 19, 2016, 6:23:23 AM4/19/16
to jenkins...@googlegroups.com

Hi

 

We have a large job that has no 'Discard old builds' setting.

 

I want to set 'Discard old builds' to a sensible value and action it, to delete some old builds, without actually running the job.  Is that possible?

 

Best regards

 

David

 

Alex Domoradov

unread,
Apr 19, 2016, 9:48:08 AM4/19/16
to Jenkins Users, David....@emea.nec.com
You can use jenkins cli

java -jar jenkins-cli.jar -s http://jenkins.example.net:8080/ delete-builds LARGE_JOB BUILD_NUMBER

for e.g.

java -jar jenkins-cli.jar -s http://jenkins.example.net:8080/ delete-builds test-job 10-20

David Aldrich

unread,
Apr 19, 2016, 10:09:59 AM4/19/16
to Alex Domoradov, Jenkins Users

Hi Alex

 

Thanks for your reply.

 

$ java -jar /var/lib/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8090/jenkins/ delete-builds Check_svn_config 1514-1515

 

ERROR: No such job 'Check_svn_config'

 

I do have a job called 'Check_svn_config'. It’s in a certain folder. Do I have to specify a path for it?

 

Best regards

 

David

 

Click here to report this email as spam.

Alex Domoradov

unread,
Apr 19, 2016, 10:23:29 AM4/19/16
to Jenkins Users, alex...@gmail.com, David....@emea.nec.com
You can get a list of jobs with the following command

# java -jar jenkins-cli.jar -s http://localhost:8090/ list-jobs

David Aldrich

unread,
Apr 19, 2016, 11:06:56 AM4/19/16
to jenkins...@googlegroups.com, alex...@gmail.com

Hi Alex

 

This isn’t working for me. I see:

 

$ java -jar /var/lib/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8090/jenkins/ list-jobs --username=daldrich

Check_svn_config

 

$ java -jar /var/lib/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8090/jenkins/ delete-builds Check_svn_config 1514-1515 --username=daldrich

 

ERROR: No such job 'Check_svn_config'

 

Any idea why please?

 

David

 

 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8a5a84e2-698d-43a3-ae34-59633bcfd687%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Domoradov

unread,
Apr 19, 2016, 12:11:13 PM4/19/16
to Jenkins Users, alex...@gmail.com, David....@emea.nec.com
It's a really strange. What version of jenkins are you using?

David Aldrich

unread,
Apr 19, 2016, 12:12:15 PM4/19/16
to Alex Domoradov, Jenkins Users

1.656

Alex Domoradov

unread,
Apr 19, 2016, 12:13:53 PM4/19/16
to Jenkins Users, alex...@gmail.com, David....@emea.nec.com
Just for test - rename the job just to "test" for example and try again

David Aldrich

unread,
Apr 19, 2016, 12:16:43 PM4/19/16
to Alex Domoradov, Jenkins Users

Got the same result:

 

ERROR: No such job 'test'

Daniel Beck

unread,
Apr 19, 2016, 4:47:32 PM4/19/16
to jenkins...@googlegroups.com

> On 19.04.2016, at 17:06, David Aldrich <David....@EMEA.NEC.COM> wrote:
>
> Any idea why please?

Use SSH key based authentication. Known bug with passwords when anon does not have read access to the job.

Alex Domoradov

unread,
Apr 20, 2016, 2:23:34 AM4/20/16
to Jenkins Users, m...@beckweb.net
Hmm, but he had used "--username=daldrich"

Daniel Beck

unread,
Apr 20, 2016, 3:35:57 AM4/20/16
to jenkins...@googlegroups.com

> On 20.04.2016, at 08:23, Alex Domoradov <alex...@gmail.com> wrote:
>
> Hmm, but he had used "--username=daldrich"

That's my point. It doesn't work like it should.

David Aldrich

unread,
Apr 20, 2016, 3:40:23 AM4/20/16
to jenkins...@googlegroups.com, Alex Domoradov, m...@beckweb.net
Hi Daniel

> Use SSH key based authentication. Known bug with passwords when anon does
> not have read access to the job.

Thanks for your reply. Could you please give me a pointer how to use SSH key based authentication? I'm running the CLI on the Jenkins master - it is accessing localhost.

Best regards

David

Alex Domoradov

unread,
Apr 20, 2016, 3:52:29 AM4/20/16
to Jenkins Users, alex...@gmail.com, m...@beckweb.net, David....@emea.nec.com
You have to add public key at user profile page

http://jenkins.example.net:8080/user/user_name/configure

Daniel Beck

unread,
Apr 20, 2016, 6:03:33 AM4/20/16
to jenkins...@googlegroups.com

> On 20.04.2016, at 09:40, David Aldrich <David....@EMEA.NEC.COM> wrote:
>
> Thanks for your reply. Could you please give me a pointer how to use SSH key based authentication? I'm running the CLI on the Jenkins master - it is accessing localhost.

https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI#JenkinsCLI-1.419andlater

David Aldrich

unread,
Apr 20, 2016, 6:08:03 AM4/20/16
to jenkins...@googlegroups.com
Hi Daniel

Thanks for the link, we're struggling to set-up the keys, possibly because we are connecting to Jenkins from the same machine that it is running on. Anyway, we are perservering.

I did find your statement confusing:

>Use SSH key based authentication. Known bug with passwords when anon does not have read access to the job.

>> Hmm, but he had used "--username=daldrich"

>That's my point. It doesn't work like it should.

So your point is that even non-anonymous access, that does have read access to the job, has the bug?

Best regards

David

> -----Original Message-----
> From: jenkins...@googlegroups.com [mailto:jenkinsci-
> us...@googlegroups.com] On Behalf Of Daniel Beck
> Sent: 20 April 2016 11:03
> To: jenkins...@googlegroups.com
> Subject: Re: How to 'Discard old builds' without running job?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/A61E8AB3-2AE5-4A33-
> ADA4-42B670BF723F%40beckweb.net.
> For more options, visit https://groups.google.com/d/optout.
>
>
> Click
> https://www.mailcontrol.com/sr/LItoQrVn!2!GX2PQPOmvUqs4kYhz3KDrV0J7M
> xfXqt59e6qcR2lA5ZhCz9oy1Rs4!d0DP6SAz4pSWoTyPktGDA== to report this
> email as spam.
Reply all
Reply to author
Forward
0 new messages