Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Using Hudson/Command-line interface"
(→Obtaining CLI) |
(→Working with Credentials) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
<br> | <br> | ||
<pre>java -jar hudson-cli.jar [-s HUDSON_URL] command [options...] [arguments...]</pre> | <pre>java -jar hudson-cli.jar [-s HUDSON_URL] command [options...] [arguments...]</pre> | ||
− | <br> HUDSON_URL can be specified via the environment variable $HUDSON_URL. The 'help' command will give you the list of the available commands, which depends on the server you are talking to. | + | <br> HUDSON_URL can be specified via the environment variable $HUDSON_URL and the -s switch can be omitted. |
+ | |||
+ | The 'help' command will give you the list of the available commands, which depends on the server you are talking to. E.g., | ||
+ | |||
+ | <pre>java -jar hudson-cli.jar -s http://localhost:8080 help</pre> | ||
+ | |||
+ | Or, in bash, | ||
+ | |||
+ | <pre> | ||
+ | export HUDSON_URL=http://localhost:8080 | ||
+ | java -jar hudson-cli.jar help | ||
+ | </pre> | ||
== <br>Extending CLI == | == <br>Extending CLI == | ||
Line 21: | Line 32: | ||
== <br>Working with Credentials == | == <br>Working with Credentials == | ||
− | If | + | If a command requires authentication, you will need to supply <code>--username</code> and <code>--password</code> as options in the CLI command. Alternatively, you can <code>login</code> once before a series of commands. |
+ | |||
+ | <pre>java -jar hudson-cli.jar login --username UN --password PW</pre> | ||
− | + | When you are finished, you can <code>logout</code>. | |
− | + | Note that not every authentication type supports these parameters for credentials. Prior to Hudson 1.373, only authentication in Hudson's own database was supported. As of 1.373, LDAP is also supported. If the CLI reports these are invalid parameters, file an issue for your authentication type and ask them to extend AbstractPasswordBasedSecurityRealm instead of directly from SecurityRealm to get support for these parameters. |
Latest revision as of 15:41, 11 June 2014
Hudson Continuous Integration Server | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Command-line Interface |
---|
Starting 1.302, Hudson has a built-in CLI client that allows you to access Hudson from a script or from your shell. This is convenient for automation of routine tasks, bulk updates, trouble diagnosis, and so on.
Obtaining CLI
Hudson CLI is distributed inside hudson.war. Download it from HUDSON_URL/jnlpJars/hudson-cli.jar. In theory, the CLI jar is dependent on the version of Hudson, but in practice, we expect to be able to retain compatibility between different versions of Hudson.
Running CLI
The general syntax is as follows (the design is similar to tools like svn/git):
java -jar hudson-cli.jar [-s HUDSON_URL] command [options...] [arguments...]
HUDSON_URL can be specified via the environment variable $HUDSON_URL and the -s switch can be omitted.
The 'help' command will give you the list of the available commands, which depends on the server you are talking to. E.g.,
java -jar hudson-cli.jar -s http://localhost:8080 help
Or, in bash,
export HUDSON_URL=http://localhost:8080 java -jar hudson-cli.jar help
Extending CLI
Plugins installed on Hudson server can add custom CLI commands to Hudson. See Writing CLI commands for more details.
Working with Credentials
If a command requires authentication, you will need to supply --username
and --password
as options in the CLI command. Alternatively, you can login
once before a series of commands.
java -jar hudson-cli.jar login --username UN --password PW
When you are finished, you can logout
.
Note that not every authentication type supports these parameters for credentials. Prior to Hudson 1.373, only authentication in Hudson's own database was supported. As of 1.373, LDAP is also supported. If the CLI reports these are invalid parameters, file an issue for your authentication type and ask them to extend AbstractPasswordBasedSecurityRealm instead of directly from SecurityRealm to get support for these parameters.