Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions stackstorm-nexus3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#visual studio
.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
./lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject
90 changes: 90 additions & 0 deletions stackstorm-nexus3/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"generator-st2pack": {
"promptValues": {
"features": [
"Sensors",
"Rules",
"Policies",
"Aliases"
],
"pack_ref": "nexus3",
"pack_name": "Sontatype Nexus3",
"pack_desc": "Sontatype nexus3 stackstorm pack"
},
"actions": {},
"aliases": {
"greet": {
"name": "greet",
"pack": "nexus3",
"description": "Greet StackStorm",
"action_ref": "nexus3.greet",
"formats": [
"greet {{greeting}}"
]
}
},
"rules": {
"on_hello_event1": {
"name": "on_hello_event1",
"pack": "nexus3",
"description": "Sample rule firing on nexus3.event1.",
"enabled": true,
"trigger": {
"type": "nexus3.event1"
},
"action": {
"ref": "nexus3.greet",
"parameters": {
"greeting": "Yo"
}
}
}
},
"sensors": {
"HelloSensor": {
"class_name": "HelloSensor",
"entry_point": "sensor1.py",
"description": "Test sensor that emits triggers.",
"trigger_types": [
{
"name": "event1",
"description": "An example trigger.",
"payload_schema": {
"type": "object"
}
}
]
}
},
"policies": {
"http.retry": {
"name": "http.retry",
"description": "Retry core.http action on timeout.",
"enabled": true,
"resource_ref": "core.http",
"policy_type": "action.retry",
"parameters": {
"retry_on": "timeout",
"max_retry_count": 2,
"delay": 2
}
},
"greet.concurrency": {
"name": "greet.concurrency",
"pack": "nexus3",
"description": "Limits the concurrent executions of the greet action.",
"enabled": true,
"resource_ref": "nexus3.greet",
"policy_type": "action.concurrency",
"parameters": {
"threshold": 10
}
}
},
"pack": {
"ref": "nexus3",
"name": "Sontatype Nexus3",
"description": "Sontatype nexus3 stackstorm pack"
}
}
}
106 changes: 106 additions & 0 deletions stackstorm-nexus3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Stackstorm-Nexus3

[Sontatype nexus3](https://www.sonatype.com/nexus-repository-oss) stackstorm pack

## Installation

Install this pack with: `st2 pack install file://$PWD`

Or if in remote repository: `st2 pack install https://github.com/MY/PACK`

## Configuration

Copy the example configuration in [nexus3.yaml.example](./nexus3.yaml.example)
to `/opt/stackstorm/configs/nexus3.yaml` and edit as required.

add nexus3 server connection profile:

* ``url`` - URL of the nexus3 server (e.g. ``http://localhost:8081``)
* ``user`` - username
* ``password`` - Password
* ``verify`` - https tls verify, only used if the `url` option specifies an `https` connection

You can also add multiple profiles:

When you add multiple profile, above parameters becomes defaults for any key missing in the profile.

``` yaml
---
url: "http://localhost:8081"
user: "admin"
password: "admin123"
verify: True
default_profile: "dev" # use this to make for missing config_profile parameter when calling any action
profiles:
"dev":
url: "http://localhost:8081"
user: "dev-user"
password: "mypas"
verify: True
"dev-2":
user: "dev2-user"
password: "mypass2"
# url : fallback to url: "http://localhost:8081"
# verify: fallback to verify: True
```

**Note** : When modifying the configuration in `/opt/stackstorm/configs/` please
remember to tell StackStorm to load these new values by running
`st2ctl reload --register-configs`

## Actions

While naming actions following convention is used:

< VERB >_< RESOURCE(plural) >
eg.
list_repositories
get_scripts

Supported Resources

* Repositories
* Scripts

### Available actions

* **list_repositories** : List nexus3 repositories
* **get_repositories** : get nexus3 repositories
* **create_repositories** : create nexus3 repository
* **delete_repositories** : delete nexus3 repository

* **list_scripts** : List nexus3 scripts
* **get_scripts** : get nexus3 scripts
* **create_scripts** : create(& upload) if missing, groovy script
* **delete_scripts** : delete nexus3 script

## Policies

* **http.retry** : Retry core.http action on timeout.

## Aliases

--NIL--

## Rules

--NIL--

## Sensors

--NIL--

## Testing

While testing you can leverage [Makefile](./tests/Makefile) to ease writing and testing actions. Read the Makefile for the list of useful commands.

## Contributing

Before submitting make sure python linter is happy with your changes first

``` bash
pip install flake8

#executing flake8 ./
make -f tests/Makefile lint
```
77 changes: 77 additions & 0 deletions stackstorm-nexus3/actions/create_repositories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: create_repositories
runner_type: python-script
description: Create a repository
enabled: true
entry_point: run.py
parameters:
action:
default: create_repositories
immutable: true
type: string
config_profile:
type: string
description: Select which nexus config profile to use.
required: false
name:
type: string
description: A unique identifier for this repository
required: true
format:
type: string
description: The format of the repository (i.e. maven2, docker, raw, nuget...)
required: true
enum:
- bower
- docker
- gitlfs
- maven
- npm
- nuget
- pypi
- raw
- rubygems
- yum
type:
type: string
description: The type of repository (i.e. group, hosted, or proxy)
required: true
enum:
- hosted
- proxy
version_policy:
type: string
description: What type of artifacts does this repository store?
required: false
default: RELEASE
enum:
- RELEASE
- SNAPSHOT
- MIXED
layout_policy:
type: string
description: Validate that all paths are maven artifact or metadata paths
required: false
default: STRICT
enum:
- STRICT
- PERMISSIVE
blob_store_name:
type: string
description: Blob store used to store asset contents
required: true
default: "default"
strict_content_type_validation:
type: boolean
description: Validate that all content uploaded to this repository is of a MIME type appropriate for the repository format
required: true
default: false
write_policy:
type: string
description: Controls if deployments of and updates to artifacts are allowed
required: true
default: ALLOW
enum:
- ALLOW_ONCE
- ALLOW
- DENY
19 changes: 19 additions & 0 deletions stackstorm-nexus3/actions/create_scripts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: create_scripts
runner_type: python-script
description: create a script
enabled: true
entry_point: run.py
parameters:
action:
default: create_scripts
immutable: true
type: string
config_profile:
type: string
description: Select which nexus config profile to use.
required: false
data:
type: object
description: instance of script to be created.
required: false
Loading