Skip to content

Commit

Permalink
NEXUS-9897
Browse files Browse the repository at this point in the history
Updated rc-open mojo to log messages in a format as closely mimicked after rc-close
Updated README.md to document addition of rc-open as of upcoming release 1.6.7
Updated WORKFLOWS.md to completely replace bare curl calls with rc-open and rc-close goal invocation
  • Loading branch information
David Ashirov committed Mar 10, 2016
1 parent 4469f55 commit 86b844e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 51 deletions.
7 changes: 7 additions & 0 deletions staging/maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ All of them accept mandatory `stagingRepositoryId` parameter, similarly to other
Hence, all these goals might operate against *one or more staging repository* (bulk operation).

All of them accept optional `description` parameter, but it's not mandatory. If not specified, a default description will be applied.
#### `rc-open` (since 1.6.7)

Creates a new staging repository from a staging profile. Example invocation:

mvn nexus-staging:rc-open -DserverId=local-nexus -DnexusUrl=http://localhost:8081/nexus -DstagingProfileId=72c1cc10566951 -DopenedRepositoryMessageFormat='The name of created repository is: %s' -DstagingDescription="The reason I open it is..."

Would create a new staging repository on the remote Nexus and log its name using the string format requested via openedRepositoryMessageFormat parameter. Parameter openedRepositoryMessageFormat is optional, if not provided the name of the newly created repository will be logged in a default format.

#### `rc-list-profiles` (since 1.5)

Expand Down
63 changes: 14 additions & 49 deletions staging/maven-plugin/WORKFLOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,33 +124,14 @@ repository lifecycle_: the entity creating it should manage it too, so is respon

Example workflow:

1) create the staging repository in some profile. Here, profile with ID "12928995ef7eaecc" is used,
and it happens using cURL on REST service:
```
$ curl -H "Content-Type: application/json" --data-binary "{\"data\":{\"description\":\"This is description\"}}" -v -X POST --user deployment:deployment123 http://localhost:8081/nexus/service/local/staging/profiles/12928995ef7eaecc/start
* About to connect() to localhost port 8081 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 8081 (#0)
* Server auth using Basic with user 'deployment'
> POST /nexus/service/local/staging/profiles/12928995ef7eaecc/start HTTP/1.1
> Authorization: Basic ZGVwbG95bWVudDpkZXBsb3ltZW50MTIz
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:8081
> Accept: */*
> Content-Type: application/json
> Content-Length: 46
>
< HTTP/1.1 201 Created
< Date: Tue, 29 May 2012 10:15:46 GMT
< Set-Cookie: rememberMe=deleteMe; Path=/nexus; Max-Age=0; Expires=Mon, 28-May-2012 10:15:46 GMT
< Content-Type: application/json; charset=UTF-8
< Date: Tue, 29 May 2012 10:15:47 GMT
< Server: Noelios-Restlet-Engine/1.1.6-SONATYPE-5348-V4
< Content-Length: 79
<
* Connection #0 to host localhost left intact
* Closing connection #0
{"data":{"stagedRepositoryId":"test1-004","description":"This is description"}}
1) create the staging repository in some profile. Here, profile with ID "12928995ef7eaecc" is used:
```
$ mvn nexus-staging:rc-open -DstagingProfileId=12928995ef7eaecc
...
[INFO] RC-Opening staging repository using staging profile ID=[12928995ef7eaecc]
[INFO] Opened test1-004
...
```

2) share the newly created staging repository ID across multiple builds, as needed,
Expand All @@ -164,28 +145,12 @@ do you want to execute builds in parallel or sequentially one by one...

3) when all the builds you needed were invoked and are done, close the staging repository:
```
$ curl -H "Content-Type: application/json" --data-binary "{\"data\":{\"description\":\"This is description\",\"stagedRepositoryId\":\"test1-004\"}}" -v -X POST --user deployment:deployment123 http://localhost:8081/nexus/service/local/staging/profiles/12928995ef7eaecc/finish
* About to connect() to localhost port 8081 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 8081 (#0)
* Server auth using Basic with user 'deployment'
> POST /nexus/service/local/staging/profiles/12928995ef7eaecc/finish HTTP/1.1
> Authorization: Basic ZGVwbG95bWVudDpkZXBsb3ltZW50MTIz
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:8081
> Accept: */*
> Content-Type: application/json
> Content-Length: 79
>
< HTTP/1.1 201 Created
< Date: Tue, 29 May 2012 10:23:06 GMT
< Set-Cookie: rememberMe=deleteMe; Path=/nexus; Max-Age=0; Expires=Mon, 28-May-2012 10:23:06 GMT
< Date: Tue, 29 May 2012 10:23:06 GMT
< Server: Noelios-Restlet-Engine/1.1.6-SONATYPE-5348-V4
< Content-Length: 0
<
* Connection #0 to host localhost left intact
* Closing connection #0
$ mvn nexus-staging:rc-close -DstagingRepositoryId=test1-004
...
[INFO] RC-Closing staging repository with IDs=[test1-004]
[INFO] Closed
...
```

This results in _artifacts of all maven invocations happened in step 2 being deployed into one staging repository_.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public class RcOpenStageRepositoryMojo
* It is important to allow end-users to output it's name in the format suitable to them.
* We provide a sensible default here
**/
@Parameter(property = "openedRepositoryMessageFormat", required = false, defaultValue = "RC-Opening staging repository with ID=%s")
@Parameter(property = "openedRepositoryMessageFormat", required = false, defaultValue = "Opened %s")
private String openedRepositoryMessageFormat;

@Override
public void doExecute(final StagingWorkflowV2Service stagingWorkflow)
throws MojoExecutionException, MojoFailureException
{
getLog().info("RC-Opening staging repository using staging profile ID=" + stagingProfileId);
getLog().info("RC-Opening staging repository using staging profile ID=[" + stagingProfileId +"]");
final String stagingRepositoryId = stagingWorkflow.startStaging(
stagingWorkflow.selectProfile(stagingProfileId),
getStagingActionMessages().getMessageForAction(StagingAction.START),
Expand Down

0 comments on commit 86b844e

Please sign in to comment.