Initial commit
This commit is contained in:
BIN
exercises/09-rest-api/solution/images/api-token.png
Normal file
BIN
exercises/09-rest-api/solution/images/api-token.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 999 KiB |
BIN
exercises/09-rest-api/solution/images/build-by-user.png
Normal file
BIN
exercises/09-rest-api/solution/images/build-by-user.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
BIN
exercises/09-rest-api/solution/images/create-user.png
Normal file
BIN
exercises/09-rest-api/solution/images/create-user.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 846 KiB |
BIN
exercises/09-rest-api/solution/images/disabled-job.png
Normal file
BIN
exercises/09-rest-api/solution/images/disabled-job.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
BIN
exercises/09-rest-api/solution/images/user-permissions.png
Normal file
BIN
exercises/09-rest-api/solution/images/user-permissions.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
50
exercises/09-rest-api/solution/solution.md
Normal file
50
exercises/09-rest-api/solution/solution.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Solution
|
||||
|
||||
Create the new user.
|
||||
|
||||

|
||||
|
||||
Add user permissions.
|
||||
|
||||

|
||||
|
||||
Generate the API token.
|
||||
|
||||

|
||||
|
||||
Generate the Jenkins crumb from the CLI.
|
||||
|
||||
```bash
|
||||
$ curl -u "buildbot:pwd" 'http://localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'
|
||||
Jenkins-Crumb:890d0b4c9c1b111deb55b196813a0ae1
|
||||
$ export JENKINS_CRUMB=Jenkins-Crumb:890d0b4c9c1b111deb55b196813a0ae1
|
||||
$ export JENKINS_API_TOKEN=11e2f3c68399b6bc3a28bc06e002be104d
|
||||
```
|
||||
|
||||
Trigger a build with the `curl` command.
|
||||
|
||||
```bash
|
||||
$ curl -X POST -H "$JENKINS_CRUMB" http://buildbot:$JENKINS_API_TOKEN@localhost:8080/job/gradle-initializr/build
|
||||
```
|
||||
|
||||
Disable the job via the REST API. You will see that the job indicated its status.
|
||||
|
||||
```bash
|
||||
$ curl -X POST -H "$JENKINS_CRUMB" http://buildbot:$JENKINS_API_TOKEN@localhost:8080/job/gradle-initializr/disable
|
||||
```
|
||||
|
||||

|
||||
|
||||
Reenable the job.
|
||||
|
||||
```bash
|
||||
$ curl -X POST -H "$JENKINS_CRUMB" http://buildbot:$JENKINS_API_TOKEN@localhost:8080/job/gradle-initializr/enable
|
||||
```
|
||||
|
||||
Download the Jenkins URL by calling the URL `localhost:8080/jnlpJars/jenkins-cli.jar` from the browser.
|
||||
|
||||
In the terminal, navigate to the directory that contains the Jenkins CLI JAR file. Use the Jenkins CLI to trigger a build with the correct command. This simply provide the password instead of the API token.
|
||||
|
||||
```bash
|
||||
$ java -jar jenkins-cli.jar -s http://localhost:8080 -auth buildbot:pwd build gradle-initializr
|
||||
```
|
||||
Reference in New Issue
Block a user