CLI/scripted way to stop scheduling any new builds on a given node?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

CLI/scripted way to stop scheduling any new builds on a given node?

Tomasz Chmielewski
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
https://lxadm.com

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6464de77-4bd9-4617-8b2c-726fdd09cabc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Robert Hales
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;">https://lxadm.com

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e2bc7eb0-9f94-46d5-912a-ebcdf1827ac5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Tomasz Chmielewski
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~#

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;">https://lxadm.com

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/39625395-86c4-4caa-a024-e990bcc29c2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Robert Hales
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~#

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;">https://lxadm.com

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b7f915b8-0ebc-48bd-a906-e035c0d6c601%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Tomasz Chmielewski
Got it, thanks:

https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~#

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;">https://lxadm.com

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/fc4c96f7-bd43-47e3-a421-d272eea8150a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Tomasz Chmielewski
Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

<a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~#

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGEm6AGAP5owqecZq_F7YlIBSELzQ&#39;;return true;">https://lxadm.com

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Devin Nusbaum
Make sure to follow https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <[hidden email]> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
https://lxadm.com


-- 
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0FD31527-DF16-4A40-A352-5B02E71BD617%40cloudbees.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Tomasz Chmielewski
nginx vhost is almost the exact copy of the vhost on https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:

upstream jenkins {
    server 127.0.0.1:8080 fail_timeout=0;
}

server {

    listen 80;
    server_name jenkins.my-domain;

    add_header X-Frame-Options SAMEORIGIN;
    include /etc/nginx/release.conf;

    access_log  /var/log/nginx/redirects-access.log vhosts;
    error_log  /var/log/nginx/redirects-error.log;

    rewrite ^ https://$host$request_uri? permanent;
}


server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              http://jenkins;
            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
            add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


So either I'm blind, or the documentation is somehow wrong?

And indeed, I can see "java.io.IOException: HTTP full-duplex channel timeout" in jenkins log.

This one indeed works:

java -jar jenkins-cli.jar -s http://localhost:8080 -auth user:pass help offline-node

But since I need to execute it from remote, I'd rather connect to https://jenkins.my-domain


On Friday, October 27, 2017 at 6:26:39 AM UTC+9, Devin Nusbaum wrote:
Make sure to follow <a href="https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ZGH4pwCcAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

<a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;">https://lxadm.com


-- 
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 <a href="javascript:" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" gdf-obfuscated-mailto="ZGH4pwCcAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-users+unsubscribe@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Devin Nusbaum
Some comments on https://issues.jenkins-ci.org/browse/JENKINS-43666 suggest that proxy_buffering off; is needed for SSL connections. (I was also testing nginx reverse proxies in the past and have that setting in my SSL config; might have forgotten to update the SSL docs with my findings) Try setting that option, and if it works I can update the  SSL section of the wiki page.

On Oct 26, 2017, at 5:43 PM, 'Tomasz Chmielewski' via Jenkins Users <[hidden email]> wrote:

nginx vhost is almost the exact copy of the vhost on https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:

upstream jenkins {
    server 127.0.0.1:8080 fail_timeout=0;
}

server {

    listen 80;
    server_name jenkins.my-domain;

    add_header X-Frame-Options SAMEORIGIN;
    include /etc/nginx/release.conf;

    access_log  /var/log/nginx/redirects-access.log vhosts;
    error_log  /var/log/nginx/redirects-error.log;

    rewrite ^ https://$host$request_uri? permanent;
}


server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              http://jenkins;
            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
            add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


So either I'm blind, or the documentation is somehow wrong?

And indeed, I can see "java.io.IOException: HTTP full-duplex channel timeout" in jenkins log.

This one indeed works:

java -jar jenkins-cli.jar -s http://localhost:8080 -auth user:pass help offline-node

But since I need to execute it from remote, I'd rather connect to https://jenkins.my-domain


On Friday, October 27, 2017 at 6:26:39 AM UTC+9, Devin Nusbaum wrote:
Make sure to follow https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@googlegroups.com> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
https://lxadm.com


-- 
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+[hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4330BA92-D768-4AE8-B213-2CC3E333C4FC%40cloudbees.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Tomasz Chmielewski
That was it! Adding proxy_buffering off helped.

For reference, here is my SSL vhost definition:

server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              http://jenkins;

            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            proxy_buffering off;

            # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
            # not used for this installation
            #add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


On Friday, October 27, 2017 at 6:56:55 AM UTC+9, Devin Nusbaum wrote:
Some comments on <a href="https://issues.jenkins-ci.org/browse/JENKINS-43666" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-43666 suggest that proxy_buffering off; is needed for SSL connections. (I was also testing nginx reverse proxies in the past and have that setting in my SSL config; might have forgotten to update the SSL docs with my findings) Try setting that option, and if it works I can update the  SSL section of the wiki page.

On Oct 26, 2017, at 5:43 PM, 'Tomasz Chmielewski' via Jenkins Users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="MPuWiKedAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com> wrote:

nginx vhost is almost the exact copy of the vhost on <a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:

upstream jenkins {
    server <a href="http://127.0.0.1:8080" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGjBsLieL8l-6V0lF6rStXOlXcB0A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGjBsLieL8l-6V0lF6rStXOlXcB0A&#39;;return true;">127.0.0.1:8080 fail_timeout=0;
}

server {

    listen 80;
    server_name jenkins.my-domain;

    add_header X-Frame-Options SAMEORIGIN;
    include /etc/nginx/release.conf;

    access_log  /var/log/nginx/redirects-access.log vhosts;
    error_log  /var/log/nginx/redirects-error.log;

    rewrite ^ <a href="https://$host$request_uri?" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://$host$request_uri?&#39;;return true;" onclick="this.href=&#39;https://$host$request_uri?&#39;;return true;">https://$host$request_uri? permanent;
}


server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;
            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


So either I'm blind, or the documentation is somehow wrong?

And indeed, I can see "java.io.IOException: HTTP full-duplex channel timeout" in jenkins log.

This one indeed works:

java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">http://localhost:8080 -auth user:pass help offline-node

But since I need to execute it from remote, I'd rather connect to <a href="https://jenkins.my-domain/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;">https://jenkins.my-domain


On Friday, October 27, 2017 at 6:26:39 AM UTC+9, Devin Nusbaum wrote:
Make sure to follow <a href="https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

<a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;">https://lxadm.com


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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 <a href="javascript:" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" gdf-obfuscated-mailto="MPuWiKedAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-users+unsubscribe@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium=email&amp;utm_source=footer" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Devin Nusbaum
Great, thanks for confirming! I’ll update the docs.

Thanks,
Devin

On Oct 26, 2017, at 6:06 PM, 'Tomasz Chmielewski' via Jenkins Users <[hidden email]> wrote:

That was it! Adding proxy_buffering off helped.

For reference, here is my SSL vhost definition:

server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              http://jenkins;

            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            proxy_buffering off;

            # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
            # not used for this installation
            #add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


On Friday, October 27, 2017 at 6:56:55 AM UTC+9, Devin Nusbaum wrote:
Some comments on https://issues.jenkins-ci.org/browse/JENKINS-43666 suggest that proxy_buffering off; is needed for SSL connections. (I was also testing nginx reverse proxies in the past and have that setting in my SSL config; might have forgotten to update the SSL docs with my findings) Try setting that option, and if it works I can update the  SSL section of the wiki page.

On Oct 26, 2017, at 5:43 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@googlegroups.com> wrote:

nginx vhost is almost the exact copy of the vhost on https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:

upstream jenkins {
    server 127.0.0.1:8080 fail_timeout=0;
}

server {

    listen 80;
    server_name jenkins.my-domain;

    add_header X-Frame-Options SAMEORIGIN;
    include /etc/nginx/release.conf;

    access_log  /var/log/nginx/redirects-access.log vhosts;
    error_log  /var/log/nginx/redirects-error.log;

    rewrite ^ https://$host$request_uri? permanent;
}


server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              http://jenkins;
            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            # workaround for https://issues.jenkins-ci.org/browse/JENKINS-45651
            add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


So either I'm blind, or the documentation is somehow wrong?

And indeed, I can see "java.io.IOException: HTTP full-duplex channel timeout" in jenkins log.

This one indeed works:

java -jar jenkins-cli.jar -s http://localhost:8080 -auth user:pass help offline-node

But since I need to execute it from remote, I'd rather connect to https://jenkins.my-domain


On Friday, October 27, 2017 at 6:26:39 AM UTC+9, Devin Nusbaum wrote:
Make sure to follow https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@googlegroups.com> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
https://lxadm.com


-- 
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+[hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
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+[hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/C342445D-9C3F-4F8A-95F2-19885BB88823%40cloudbees.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Tomasz Chmielewski
Actually, I still didn't find a solution to my problem.

1) I don't understand the purpose of "wait-node-offline"

java -jar jenkins-cli.jar -s https://jenkins.my-domain -auth user:pass wait-node-offline some-node

This will never exit, unless I use "offline-node" first. But "offline-node" exits immediately.

To be precise: actually "wait-node-offline" will crash after some time and will never exit if used through a reverse proxy like nginx. But it will never exit if connecting to jenkins directly.


2) "offline-node" exits immediately and the node is set to "offline":

java -jar jenkins-cli.jar -s https://jenkins.my-domain -auth user:pass offline-node some-node

The builds which were running will continue to run until finished (existing builds are not interrupted) - this is expected.


3) So my reasoning is that I need some kind of:

java -jar jenkins-cli.jar -s https://jenkins.my-domain -auth user:pass list-jobs some-view

But only showing the builds which are currently running (for a given view, or for a given node). Then parse it, and decide if the node is really offline (as in, not accepting any new builds, and not running any builds right now) or not.


Unfortunately, I don't see such an option in https://jenkins.my-domain/cli/



On Friday, October 27, 2017 at 7:25:43 AM UTC+9, Devin Nusbaum wrote:
Great, thanks for confirming! I’ll update the docs.

Thanks,
Devin

On Oct 26, 2017, at 6:06 PM, 'Tomasz Chmielewski' via Jenkins Users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="I1JQvzmfAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com> wrote:

That was it! Adding proxy_buffering off helped.

For reference, here is my SSL vhost definition:

server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;

            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            proxy_buffering off;

            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            # not used for this installation
            #add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


On Friday, October 27, 2017 at 6:56:55 AM UTC+9, Devin Nusbaum wrote:
Some comments on <a href="https://issues.jenkins-ci.org/browse/JENKINS-43666" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-43666 suggest that proxy_buffering off; is needed for SSL connections. (I was also testing nginx reverse proxies in the past and have that setting in my SSL config; might have forgotten to update the SSL docs with my findings) Try setting that option, and if it works I can update the  SSL section of the wiki page.

On Oct 26, 2017, at 5:43 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

nginx vhost is almost the exact copy of the vhost on <a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:

upstream jenkins {
    server <a href="http://127.0.0.1:8080/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNESqqXBB-8ZOA3oQHQikMlCJ1EGSw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNESqqXBB-8ZOA3oQHQikMlCJ1EGSw&#39;;return true;">127.0.0.1:8080 fail_timeout=0;
}

server {

    listen 80;
    server_name jenkins.my-domain;

    add_header X-Frame-Options SAMEORIGIN;
    include /etc/nginx/release.conf;

    access_log  /var/log/nginx/redirects-access.log vhosts;
    error_log  /var/log/nginx/redirects-error.log;

    rewrite ^ <a href="https://$host$request_uri?" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://$host$request_uri?&#39;;return true;" onclick="this.href=&#39;https://$host$request_uri?&#39;;return true;">https://$host$request_uri? permanent;
}


server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;
            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


So either I'm blind, or the documentation is somehow wrong?

And indeed, I can see "java.io.IOException: HTTP full-duplex channel timeout" in jenkins log.

This one indeed works:

java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">http://localhost:8080 -auth user:pass help offline-node

But since I need to execute it from remote, I'd rather connect to <a href="https://jenkins.my-domain/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;">https://jenkins.my-domain


On Friday, October 27, 2017 at 6:26:39 AM UTC+9, Devin Nusbaum wrote:
Make sure to follow <a href="https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

<a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;">https://lxadm.com


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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 <a href="javascript:" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" gdf-obfuscated-mailto="I1JQvzmfAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-users+unsubscribe@....
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium=email&amp;utm_source=footer" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/fb7bee5a-6561-4373-8342-6855ad5ee39f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Robert Hales
I think wait-offline-node is supposed to just wait until the node is actually offline. So you are supposed to run offline-node, then in your script you can wait-offline-node before you do whatever what you wanted to do after the node was offline. I would assume the node is not configured offline until there are no jobs running on it, but that may be a bad assumption. 

Try kicking off a long-running job (with a sh"sleep 500") and then try to offline the node and then run wait-offline-node to see if it shows it offline immediately, or if it waits until the job finishes. 

If it isn't actually waiting for the jobs to finish, well, that sucks. But the wait-offline-node is still probably supposed to wait for a node to go offline. There may be other things that cause the node to take a long time to go offline. 


On Thursday, October 26, 2017 at 11:03:04 PM UTC-6, Tomasz Chmielewski wrote:
Actually, I still didn't find a solution to my problem.

1) I don't understand the purpose of "wait-node-offline"

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass wait-node-offline some-node

This will never exit, unless I use "offline-node" first. But "offline-node" exits immediately.

To be precise: actually "wait-node-offline" will crash after some time and will never exit if used through a reverse proxy like nginx. But it will never exit if connecting to jenkins directly.


2) "offline-node" exits immediately and the node is set to "offline":

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass offline-node some-node

The builds which were running will continue to run until finished (existing builds are not interrupted) - this is expected.


3) So my reasoning is that I need some kind of:

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass list-jobs some-view

But only showing the builds which are currently running (for a given view, or for a given node). Then parse it, and decide if the node is really offline (as in, not accepting any new builds, and not running any builds right now) or not.


Unfortunately, I don't see such an option in <a href="https://jenkins.my-domain/cli/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2Fcli%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECZZVXy_NGZAqs58uqQztHgoO_mw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2Fcli%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECZZVXy_NGZAqs58uqQztHgoO_mw&#39;;return true;">https://jenkins.my-domain/cli/



On Friday, October 27, 2017 at 7:25:43 AM UTC+9, Devin Nusbaum wrote:
Great, thanks for confirming! I’ll update the docs.

Thanks,
Devin

On Oct 26, 2017, at 6:06 PM, 'Tomasz Chmielewski' via Jenkins Users <[hidden email]> wrote:

That was it! Adding proxy_buffering off helped.

For reference, here is my SSL vhost definition:

server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;

            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            proxy_buffering off;

            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            # not used for this installation
            #add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


On Friday, October 27, 2017 at 6:56:55 AM UTC+9, Devin Nusbaum wrote:
Some comments on <a href="https://issues.jenkins-ci.org/browse/JENKINS-43666" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-43666 suggest that proxy_buffering off; is needed for SSL connections. (I was also testing nginx reverse proxies in the past and have that setting in my SSL config; might have forgotten to update the SSL docs with my findings) Try setting that option, and if it works I can update the  SSL section of the wiki page.

On Oct 26, 2017, at 5:43 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

nginx vhost is almost the exact copy of the vhost on <a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:

upstream jenkins {
    server <a href="http://127.0.0.1:8080/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNESqqXBB-8ZOA3oQHQikMlCJ1EGSw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNESqqXBB-8ZOA3oQHQikMlCJ1EGSw&#39;;return true;">127.0.0.1:8080 fail_timeout=0;
}

server {

    listen 80;
    server_name jenkins.my-domain;

    add_header X-Frame-Options SAMEORIGIN;
    include /etc/nginx/release.conf;

    access_log  /var/log/nginx/redirects-access.log vhosts;
    error_log  /var/log/nginx/redirects-error.log;

    rewrite ^ <a href="https://$host$request_uri?" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://$host$request_uri?&#39;;return true;" onclick="this.href=&#39;https://$host$request_uri?&#39;;return true;">https://$host$request_uri? permanent;
}


server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;
            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


So either I'm blind, or the documentation is somehow wrong?

And indeed, I can see "java.io.IOException: HTTP full-duplex channel timeout" in jenkins log.

This one indeed works:

java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">http://localhost:8080 -auth user:pass help offline-node

But since I need to execute it from remote, I'd rather connect to <a href="https://jenkins.my-domain/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;">https://jenkins.my-domain


On Friday, October 27, 2017 at 6:26:39 AM UTC+9, Devin Nusbaum wrote:
Make sure to follow <a href="https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

<a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;">https://lxadm.com


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium=email&amp;utm_source=footer" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d71c2c0f-8de2-49d0-8786-897d777c949e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Tomasz Chmielewski
Unfortunately it doesn't work this way. If there is a long running job, "wait-node-offline" will not wait for it to finish.

# time java -jar jenkins-cli.jar -s https://jenkins.my-domain -auth user:pass offline-node jenkins-node

real    0m1.249s
user    0m0.834s
sys     0m0.049s


At this point, I can see the node is set to offline in Build Executor Status in Jenkins webgui, and the job which was running before starting the command continues to run.


# time java -jar jenkins-cli.jar -s https://jenkins.my-domain -auth user:pass wait-node-offline jenkins-node

real    0m1.949s
user    0m0.817s
sys     0m0.061s


At this point, I can still see the node is set to offline in Build Executor Status in Jenkins webgui, and the job which was running before starting the command continues to run.


So yeah, that sucks, because there doesn't seem to be a good way to offline a jenkins node gracefully.



On Friday, October 27, 2017 at 2:47:37 PM UTC+9, Robert Hales wrote:
I think wait-offline-node is supposed to just wait until the node is actually offline. So you are supposed to run offline-node, then in your script you can wait-offline-node before you do whatever what you wanted to do after the node was offline. I would assume the node is not configured offline until there are no jobs running on it, but that may be a bad assumption. 

Try kicking off a long-running job (with a sh"sleep 500") and then try to offline the node and then run wait-offline-node to see if it shows it offline immediately, or if it waits until the job finishes. 

If it isn't actually waiting for the jobs to finish, well, that sucks. But the wait-offline-node is still probably supposed to wait for a node to go offline. There may be other things that cause the node to take a long time to go offline. 


On Thursday, October 26, 2017 at 11:03:04 PM UTC-6, Tomasz Chmielewski wrote:
Actually, I still didn't find a solution to my problem.

1) I don't understand the purpose of "wait-node-offline"

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass wait-node-offline some-node

This will never exit, unless I use "offline-node" first. But "offline-node" exits immediately.

To be precise: actually "wait-node-offline" will crash after some time and will never exit if used through a reverse proxy like nginx. But it will never exit if connecting to jenkins directly.


2) "offline-node" exits immediately and the node is set to "offline":

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass offline-node some-node

The builds which were running will continue to run until finished (existing builds are not interrupted) - this is expected.


3) So my reasoning is that I need some kind of:

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass list-jobs some-view

But only showing the builds which are currently running (for a given view, or for a given node). Then parse it, and decide if the node is really offline (as in, not accepting any new builds, and not running any builds right now) or not.


Unfortunately, I don't see such an option in <a href="https://jenkins.my-domain/cli/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2Fcli%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECZZVXy_NGZAqs58uqQztHgoO_mw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2Fcli%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECZZVXy_NGZAqs58uqQztHgoO_mw&#39;;return true;">https://jenkins.my-domain/cli/



On Friday, October 27, 2017 at 7:25:43 AM UTC+9, Devin Nusbaum wrote:
Great, thanks for confirming! I’ll update the docs.

Thanks,
Devin

On Oct 26, 2017, at 6:06 PM, 'Tomasz Chmielewski' via Jenkins Users <[hidden email]> wrote:

That was it! Adding proxy_buffering off helped.

For reference, here is my SSL vhost definition:

server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;

            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            proxy_buffering off;

            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            # not used for this installation
            #add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


On Friday, October 27, 2017 at 6:56:55 AM UTC+9, Devin Nusbaum wrote:
Some comments on <a href="https://issues.jenkins-ci.org/browse/JENKINS-43666" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-43666 suggest that proxy_buffering off; is needed for SSL connections. (I was also testing nginx reverse proxies in the past and have that setting in my SSL config; might have forgotten to update the SSL docs with my findings) Try setting that option, and if it works I can update the  SSL section of the wiki page.

On Oct 26, 2017, at 5:43 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

nginx vhost is almost the exact copy of the vhost on <a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:

upstream jenkins {
    server <a href="http://127.0.0.1:8080/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNESqqXBB-8ZOA3oQHQikMlCJ1EGSw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNESqqXBB-8ZOA3oQHQikMlCJ1EGSw&#39;;return true;">127.0.0.1:8080 fail_timeout=0;
}

server {

    listen 80;
    server_name jenkins.my-domain;

    add_header X-Frame-Options SAMEORIGIN;
    include /etc/nginx/release.conf;

    access_log  /var/log/nginx/redirects-access.log vhosts;
    error_log  /var/log/nginx/redirects-error.log;

    rewrite ^ <a href="https://$host$request_uri?" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://$host$request_uri?&#39;;return true;" onclick="this.href=&#39;https://$host$request_uri?&#39;;return true;">https://$host$request_uri? permanent;
}


server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;
            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


So either I'm blind, or the documentation is somehow wrong?

And indeed, I can see "java.io.IOException: HTTP full-duplex channel timeout" in jenkins log.

This one indeed works:

java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">http://localhost:8080 -auth user:pass help offline-node

But since I need to execute it from remote, I'd rather connect to <a href="https://jenkins.my-domain/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;">https://jenkins.my-domain


On Friday, October 27, 2017 at 6:26:39 AM UTC+9, Devin Nusbaum wrote:
Make sure to follow <a href="https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

<a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;">https://lxadm.com


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium=email&amp;utm_source=footer" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/888e579a-7b9d-4255-87c7-31e78c28f614%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: CLI/scripted way to stop scheduling any new builds on a given node?

Robert Hales
Looks like you will have to look at writing a groovy script, maybe. You could offline it in a groovy script, then there must be some way to get the status of the node. Can probably put that in a 'while' loop until the node is idle. Then do your other work. You can send a groovy script to the script console through http on the rest API. I can shove you in the right direction, but that's about all the more help I will probably be, though I'd be interested in seeing your script when/if you do it. These links should get you started. 

https://wiki.jenkins.io/display/JENKINS/Jenkins+Script+Console

https://stackoverflow.com/questions/37227562/how-to-know-whether-the-jenkins-build-executors-are-idle-or-not-in-jenkins-using
https://wiki.jenkins.io/display/JENKINS/Add+a+new+label+to+slaves+meeting+a+condition
https://wiki.jenkins.io/display/JENKINS/Display+Information+About+Nodes
https://wiki.jenkins.io/display/JENKINS/Monitor+and+Restart+Offline+Slaves
https://wiki.jenkins.io/display/JENKINS/Wipe+workspaces+for+a+set+of+jobs+on+all+nodes


You could look into the rest API, too. You can offline the node in the api: 

http://jenkins/computer/${NODE}/toggleOffline?offlineMessage=Taken_down

I can't find a way to see the executor status that works. I would think 

http://jenkins/computer/${NODE}/api/json?pretty=true

would do it, but in a quick test, it didn't seem to show different if the executors were busy or not. 

Let me know what you come up with. 



On Friday, October 27, 2017 at 5:29:00 AM UTC-6, Tomasz Chmielewski wrote:
Unfortunately it doesn't work this way. If there is a long running job, "wait-node-offline" will not wait for it to finish.

# time java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass offline-node jenkins-node

real    0m1.249s
user    0m0.834s
sys     0m0.049s


At this point, I can see the node is set to offline in Build Executor Status in Jenkins webgui, and the job which was running before starting the command continues to run.


# time java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass wait-node-offline jenkins-node

real    0m1.949s
user    0m0.817s
sys     0m0.061s


At this point, I can still see the node is set to offline in Build Executor Status in Jenkins webgui, and the job which was running before starting the command continues to run.


So yeah, that sucks, because there doesn't seem to be a good way to offline a jenkins node gracefully.



On Friday, October 27, 2017 at 2:47:37 PM UTC+9, Robert Hales wrote:
I think wait-offline-node is supposed to just wait until the node is actually offline. So you are supposed to run offline-node, then in your script you can wait-offline-node before you do whatever what you wanted to do after the node was offline. I would assume the node is not configured offline until there are no jobs running on it, but that may be a bad assumption. 

Try kicking off a long-running job (with a sh"sleep 500") and then try to offline the node and then run wait-offline-node to see if it shows it offline immediately, or if it waits until the job finishes. 

If it isn't actually waiting for the jobs to finish, well, that sucks. But the wait-offline-node is still probably supposed to wait for a node to go offline. There may be other things that cause the node to take a long time to go offline. 


On Thursday, October 26, 2017 at 11:03:04 PM UTC-6, Tomasz Chmielewski wrote:
Actually, I still didn't find a solution to my problem.

1) I don't understand the purpose of "wait-node-offline"

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass wait-node-offline some-node

This will never exit, unless I use "offline-node" first. But "offline-node" exits immediately.

To be precise: actually "wait-node-offline" will crash after some time and will never exit if used through a reverse proxy like nginx. But it will never exit if connecting to jenkins directly.


2) "offline-node" exits immediately and the node is set to "offline":

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass offline-node some-node

The builds which were running will continue to run until finished (existing builds are not interrupted) - this is expected.


3) So my reasoning is that I need some kind of:

java -jar jenkins-cli.jar -s <a href="https://jenkins.my-domain" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGPzduEZRtLhtG0m0bgsXJXJp2uJQ&#39;;return true;">https://jenkins.my-domain -auth user:pass list-jobs some-view

But only showing the builds which are currently running (for a given view, or for a given node). Then parse it, and decide if the node is really offline (as in, not accepting any new builds, and not running any builds right now) or not.


Unfortunately, I don't see such an option in <a href="https://jenkins.my-domain/cli/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2Fcli%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECZZVXy_NGZAqs58uqQztHgoO_mw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2Fcli%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECZZVXy_NGZAqs58uqQztHgoO_mw&#39;;return true;">https://jenkins.my-domain/cli/



On Friday, October 27, 2017 at 7:25:43 AM UTC+9, Devin Nusbaum wrote:
Great, thanks for confirming! I’ll update the docs.

Thanks,
Devin

On Oct 26, 2017, at 6:06 PM, 'Tomasz Chmielewski' via Jenkins Users <[hidden email]> wrote:

That was it! Adding proxy_buffering off helped.

For reference, here is my SSL vhost definition:

server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;

            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            proxy_buffering off;

            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            # not used for this installation
            #add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


On Friday, October 27, 2017 at 6:56:55 AM UTC+9, Devin Nusbaum wrote:
Some comments on <a href="https://issues.jenkins-ci.org/browse/JENKINS-43666" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-43666\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHnxU-8lYj22Kr3uFv6uDKFPW5MWQ&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-43666 suggest that proxy_buffering off; is needed for SSL connections. (I was also testing nginx reverse proxies in the past and have that setting in my SSL config; might have forgotten to update the SSL docs with my findings) Try setting that option, and if it works I can update the  SSL section of the wiki page.

On Oct 26, 2017, at 5:43 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

nginx vhost is almost the exact copy of the vhost on <a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2Bbehind%2Ban%2BNGinX%2Breverse%2Bproxy%3A\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGuV_sNKYimWMnXYEDoCgsM5Gp2Vw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy:

upstream jenkins {
    server <a href="http://127.0.0.1:8080/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNESqqXBB-8ZOA3oQHQikMlCJ1EGSw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2F127.0.0.1%3A8080%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNESqqXBB-8ZOA3oQHQikMlCJ1EGSw&#39;;return true;">127.0.0.1:8080 fail_timeout=0;
}

server {

    listen 80;
    server_name jenkins.my-domain;

    add_header X-Frame-Options SAMEORIGIN;
    include /etc/nginx/release.conf;

    access_log  /var/log/nginx/redirects-access.log vhosts;
    error_log  /var/log/nginx/redirects-error.log;

    rewrite ^ <a href="https://$host$request_uri?" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://$host$request_uri?&#39;;return true;" onclick="this.href=&#39;https://$host$request_uri?&#39;;return true;">https://$host$request_uri? permanent;
}


server {

        listen 443 ssl;

        server_name jenkins.my-domain;

        ssl_certificate ssl/my-domain.crt;
        ssl_certificate_key ssl/my-domain.key;
        ssl_dhparam ssl/dhparam-2048.pem;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
        add_header X-Frame-Options SAMEORIGIN;

        access_log  /var/log/nginx/jenkins.my-domain.access.log;
        error_log /var/log/nginx/jenkins.my-domain.error.log;

        location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;
            proxy_redirect http:// https://;
            proxy_pass              <a href="http://jenkins/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjenkins%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHmOzDZrHs-QVVXSW1tDQJLlUlY4w&#39;;return true;">http://jenkins;
            # Required for new HTTP-based CLI
            proxy_http_version 1.1;
            proxy_request_buffering off;
            # workaround for <a href="https://issues.jenkins-ci.org/browse/JENKINS-45651" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-45651\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH9i83Ur0iED0TYU9BkpsIHH5UUjw&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-45651
            add_header 'X-SSH-Endpoint' 'jenkins.my-domain:22' always;
        }
}


So either I'm blind, or the documentation is somehow wrong?

And indeed, I can see "java.io.IOException: HTTP full-duplex channel timeout" in jenkins log.

This one indeed works:

java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">http://localhost:8080 -auth user:pass help offline-node

But since I need to execute it from remote, I'd rather connect to <a href="https://jenkins.my-domain/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.my-domain%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvlKVGZQh1x512J_XmLazyRBN5dQ&#39;;return true;">https://jenkins.my-domain


On Friday, October 27, 2017 at 6:26:39 AM UTC+9, Devin Nusbaum wrote:
Make sure to follow <a href="https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FRunning%2BJenkins%2Bbehind%2BNginx\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGn8kHxuDDp_epGU2uhirvn8MBuHw&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx if Nginx is configured as a a reverse proxy.

Notably proxy_http_version 1.1; and  proxy_request_buffering off; are required for your version of Jenkins. (If your Jenkins logs at the time you try to connect via CLI have errors that say something to the effect of “Full-duplex channel timeout” then I expect those settings to fix it.)

On Oct 26, 2017, at 5:18 PM, 'Tomasz Chmielewski' via Jenkins Users <jenkins...@<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">googlegroups.<a href="http://googlegroups.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://googlegroups.com/&#39;;return true;" onclick="this.href=&#39;http://googlegroups.com/&#39;;return true;">com> wrote:

Except... it doesn't seem to work.

$ java -jar jenkins-cli.jar -s <a href="https://jenkins-url/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins-url%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFJQiAx19hJszI6E9l4piq8X7zFNg&#39;;return true;">https://jenkins-url -auth user:pass help offline-node
$ echo $?
255

In nginx log:

10.11.0.8 - user [26/Oct/2017:21:11:51 +0000] "GET / HTTP/1.1" 200 150393 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:11:52 +0000] "GET /crumbIssuer/api/xml/?xpath=concat(//crumbRequestField,\x22:\x22,//crumb) HTTP/1.1" 404 335 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 200 11 "-" "Java/1.8.0_131"
10.11.0.8 - user [26/Oct/2017:21:12:07 +0000] "POST /cli?remoting=false HTTP/1.1" 500 13912 "-" "Java/1.8.0_131"

How do I debug this?



On Friday, October 27, 2017 at 6:07:03 AM UTC+9, Tomasz Chmielewski wrote:
Got it, thanks:

<a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FJenkins%2BCLI\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBIDa5cSbxHjfpVTf4_CfEc86nSg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

On Friday, October 27, 2017 at 5:57:18 AM UTC+9, Robert Hales wrote:
You have to use the Jenkins CLI. I guess that can be a bit confusing. It isn't a script available to run at the command line. Jenkins has their own CLI. If you google for it, you will find the details pretty easily. 

On Thursday, October 26, 2017 at 2:55:07 PM UTC-6, Tomasz Chmielewski wrote:
Hmm, where do I find "offline-node" command?

root@jenkins:~# dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

root@jenkins:~# find / -name offline-node

root@jenkins:~# 

root@jenkins:~# dpkg -l | grep jenkins
ii  jenkins                          2.73.2       (...)



On Friday, October 27, 2017 at 12:21:17 AM UTC+9, Robert Hales wrote:
In the CLI, use the 'offline-node' command. Another useful command in what it looks like you want to do might be "wait-offline-node".

You could also create a groovy script to do it and run that from the REST API. 

On Thursday, October 26, 2017 at 3:35:29 AM UTC-6, Tomasz Chmielewski wrote:
Is there a CLI/scripted way to stop scheduling any new builds on a given node?

Basically, any builds currently running on a given node should continue to run until they are finished -- and no new builds should be started.

Think of "retiring" a node, and replacing it with a new one -- but allowing any existing jobs to finish gracefully.



Tomasz Chmielewski
<a href="https://lxadm.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Flxadm.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE2_NwuRmbefeX6N_SaNwRjWdgkxA&#39;;return true;">https://lxadm.com


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/a19302b1-6ed1-44bb-b65b-28868a64708b%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/476c0ec2-753f-45bd-944b-2f9dcf60deae%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


-- 
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+[hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium=email&amp;utm_source=footer" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/cb454333-dddf-4186-ac97-66550f856454%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4e8dcbbe-225b-4d59-b021-e196a3e94a63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.