Re: How to create/update Jenkins job via REST API in Java?

2022-04-11 Thread 'Daniel Beck' via Jenkins Users
On Mon, Apr 4, 2022 at 11:13 AM Jon Brohauge  wrote:

> Whenever I try to POST a job, using a Basic Authentication with the
> “username:password” base64 encoded, I get a 403.
>

Crumbs are session-specific since 2.176.2:
https://www.jenkins.io/doc/upgrade-guide/2.176/#upgrading-to-jenkins-lts-2-176-2

Either use an API token, or record the `Set-Cookie` response header and it
the same session ID with every subsequent request.


> Whenever I try to POST a job, using a Basic Authentication with the
> “username:apitoken” base64 encoded, I get a 500. The apitoken has been
> handmade just for this test.
>

The reason for the HTTP 500 is something the logs on Jenkins should tell
you. My guess is you forgot to set `Content-Type: text/xml` as documented
in `/job/whatever/api/`.

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAMo7PtK7WUYUD5AV%2BQr8MvdJ8fjJrJCa5%2B4dNwKedTs_a0OLxA%40mail.gmail.com.


Re: Reasons for workspace cleanup

2022-04-11 Thread Fabian Cenedese


>>Workspaces Jenkins considers "unused" are wiped periodically. While this is 
>>intended to be safe, i.e., never delete the last workspace, or workspaces of 
>>running builds, it's not impossible that "active" workspaces are caught in 
>>rare circumstances. Check the workspace cleanup log in your Jenkins home to 
>>see whether this happens to you, or enable detailed (FINE) logging for the 
>>logger "hudson.model.WorkspaceCleanupThread".
>
>Thanks for the info, that's what seems to be happening. I'll see if I can
>check this in case it happens again. Is this something that can be
>influenced in the settings or is it completely automatic? Would I need
>to run a job more often to prevent this? Or I could put all my files in
>a different directory outside the workspace and change into it in
>the job. That way there's nothing to delete in the configured workspace.
>
>
>This is completely automated and invisible beyond log entries (probably not 
>great). While there are some possible approaches to stop Jenkins from doing 
>that when it occurs with regular Jenkins jobs, your situation is different. In 
>your particular case, you're using what amounts to a Jenkins-managed resource 
>outside Jenkins. The cleanest solution is what you suggest: to stop doing 
>that, run your cron job somewhere else, and limit Jenkins workspace use to 
>actual Jenkins jobs.

Well, I do use Jenkins to collect the results of my otherwise started script,
keep the history, send emails and so on. But I understand that it knows
nothing of it until the job is started to get the results.
I'll rearrange my layout to have s separate directory for Jenkins.

Thanks for your help.

bye  Fabi

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/20220411125351.D3AC24B6A594%40macserver.private.


Re: Reasons for workspace cleanup

2022-04-11 Thread 'Daniel Beck' via Jenkins Users
On Mon, Apr 11, 2022 at 2:05 PM Fabian Cenedese  wrote:

> At 13:53 11.04.2022, you wrote:
>
> >Workspaces Jenkins considers "unused" are wiped periodically. While this
> is intended to be safe, i.e., never delete the last workspace, or
> workspaces of running builds, it's not impossible that "active" workspaces
> are caught in rare circumstances. Check the workspace cleanup log in your
> Jenkins home to see whether this happens to you, or enable detailed (FINE)
> logging for the logger "hudson.model.WorkspaceCleanupThread".
>
> Thanks for the info, that's what seems to be happening. I'll see if I can
> check this in case it happens again. Is this something that can be
> influenced in the settings or is it completely automatic? Would I need
> to run a job more often to prevent this? Or I could put all my files in
> a different directory outside the workspace and change into it in
> the job. That way there's nothing to delete in the configured workspace.
>

This is completely automated and invisible beyond log entries (probably not
great). While there are some possible approaches to stop Jenkins from doing
that when it occurs with regular Jenkins jobs, your situation is different.
In your particular case, you're using what amounts to a Jenkins-managed
resource outside Jenkins. The cleanest solution is what you suggest: to
stop doing that, run your cron job somewhere else, and limit Jenkins
workspace use to actual Jenkins jobs.

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAMo7Pt%2BxqNi77CWva8KtkCcwNMsGrjkd6qJRR5nH_16KG4sq2Q%40mail.gmail.com.


Re: Reasons for workspace cleanup

2022-04-11 Thread Fabian Cenedese
At 13:53 11.04.2022, you wrote:

>Workspaces Jenkins considers "unused" are wiped periodically. While this is 
>intended to be safe, i.e., never delete the last workspace, or workspaces of 
>running builds, it's not impossible that "active" workspaces are caught in 
>rare circumstances. Check the workspace cleanup log in your Jenkins home to 
>see whether this happens to you, or enable detailed (FINE) logging for the 
>logger "hudson.model.WorkspaceCleanupThread".

Thanks for the info, that's what seems to be happening. I'll see if I can
check this in case it happens again. Is this something that can be
influenced in the settings or is it completely automatic? Would I need
to run a job more often to prevent this? Or I could put all my files in
a different directory outside the workspace and change into it in
the job. That way there's nothing to delete in the configured workspace.

Thanks

bye  Fabi

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/20220411120545.DC9DF4B6A0AA%40macserver.private.


Re: Reasons for workspace cleanup

2022-04-11 Thread 'Daniel Beck' via Jenkins Users
Workspaces Jenkins considers "unused" are wiped periodically. While this is
intended to be safe, i.e., never delete the last workspace, or workspaces
of running builds, it's not impossible that "active" workspaces are caught
in rare circumstances. Check the workspace cleanup log in your Jenkins home
to see whether this happens to you, or enable detailed (FINE) logging for
the logger "hudson.model.WorkspaceCleanupThread".

(Code reference in case you're curious:
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/WorkspaceCleanupThread.java
)

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAMo7PtLhDo_Ntn_HwZCk4zVy4qP1drqfsdNFsKaDefKh8s4awA%40mail.gmail.com.