mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-12 00:05:49 +08:00
Compare commits
427 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d06ffc01c1 | |||
| 85a676bfd7 | |||
| 7c3a8b283a | |||
| db48270276 | |||
| 0120fc220b | |||
| 86e28b1256 | |||
| f7c867403d | |||
| 65009cbda6 | |||
| 4304bcedb3 | |||
| a1400c985d | |||
| 625171aa24 | |||
| 04f57f5f0e | |||
| dd913c92b1 | |||
| 8063cbe254 | |||
| ed58d20239 | |||
| c99cacf8e5 | |||
| 1bd3a222e0 | |||
| 2c724b5972 | |||
| a8a76a7b1e | |||
| 41cc972a6e | |||
| c253de7654 | |||
| e2a43d69f6 | |||
| d20dda0d1e | |||
| 9c3f6ce289 | |||
| fe82f409d0 | |||
| eb293947b5 | |||
| b703e0a7d7 | |||
| 1cf39ceb1b | |||
| 134cffbe71 | |||
| 38474872a0 | |||
| 49cd6b8c78 | |||
| 2e21981438 | |||
| afc0d7896a | |||
| 2e58029a96 | |||
| 80a4416636 | |||
| 3ef9aea393 | |||
| bf2f085f63 | |||
| f7a604dc6b | |||
| c1153c4b91 | |||
| 64d0152d7a | |||
| 5ac0323dc5 | |||
| ee25a92a84 | |||
| fb4ef3151e | |||
| f972cb7ea0 | |||
| eff73b239d | |||
| 8a5150d3c2 | |||
| 13bd1e5d92 | |||
| ceff4e7641 | |||
| ec0855f7cb | |||
| 074e0bfd5e | |||
| 06520eb502 | |||
| 45ea8e67c7 | |||
| adfd5fdbd9 | |||
| 5a796027b8 | |||
| 162ea4b86f | |||
| ed4f3a253e | |||
| f1d20e06f1 | |||
| a72cf9566e | |||
| eaf7fdc666 | |||
| 2300ba896e | |||
| d7a1cbd9a6 | |||
| ac4057b57d | |||
| 89310fb576 | |||
| d8e9709ef0 | |||
| 879f94d6bf | |||
| 25432ff633 | |||
| fa974055b8 | |||
| b09cecc467 | |||
| 90774c5e4a | |||
| 39de721118 | |||
| d2caa874cf | |||
| 51dd9e6a27 | |||
| 656f00e6c3 | |||
| de1640533d | |||
| 1d9b75d383 | |||
| 97fed6ec95 | |||
| 684cea1eed | |||
| 09d4653a85 | |||
| a343407dc0 | |||
| fdd7389b05 | |||
| dfb2ccea7f | |||
| 06eb0c4e33 | |||
| a4747963fd | |||
| b550d25288 | |||
| 57c6d5534f | |||
| ad6e19bf22 | |||
| 4e994b0af9 | |||
| 29b5c3e071 | |||
| 60261ed05e | |||
| be65e70753 | |||
| 30dcff9bf2 | |||
| 4ddcfe5843 | |||
| dc70c1232b | |||
| 712fea742c | |||
| 6da4e99f6e | |||
| 2ba0ae16c3 | |||
| dd92e98a57 | |||
| ffb873a39b | |||
| 499a91c156 | |||
| be814177e9 | |||
| ab664173c6 | |||
| 7669be9e26 | |||
| de15375a60 | |||
| 40b0fc9e3c | |||
| 81b7b67684 | |||
| e6d8814f92 | |||
| e204770e52 | |||
| e4252b9282 | |||
| d80c14480e | |||
| a4fae4024d | |||
| 52fa27d07a | |||
| 4a3e3d7344 | |||
| 268ea183e3 | |||
| c29ea0c1c0 | |||
| 21b6739860 | |||
| dab358be20 | |||
| 00b26a6024 | |||
| 39d3d4092c | |||
| 361aa89eba | |||
| 3835f74748 | |||
| 4c44e52acf | |||
| bc43503d76 | |||
| 033e2b9038 | |||
| 0e3f5e55fa | |||
| b8227c6eb7 | |||
| f971349eef | |||
| fbeab14fb7 | |||
| d47b56a6d1 | |||
| bbae39e33a | |||
| 5e8c1f94f3 | |||
| 02430100a5 | |||
| 4ccfd15f81 | |||
| 42f915d25e | |||
| 783a4c597d | |||
| 6412b866e9 | |||
| 2139b8a41d | |||
| 18af7969c4 | |||
| e6923122c3 | |||
| 17c084c58d | |||
| 9fc918bcdd | |||
| 452305c241 | |||
| 368fd0e83c | |||
| 58f43d2838 | |||
| 83fbfa9571 | |||
| c2f54fb876 | |||
| a8398d8de4 | |||
| 481a4a47bb | |||
| e3018b0429 | |||
| 0152070931 | |||
| 19f1eb4ca3 | |||
| 80b6b5f3ec | |||
| 6e4b242aa4 | |||
| 64ecccbb55 | |||
| 76229a5532 | |||
| 540ba3b50e | |||
| c693a73511 | |||
| d75fc920f9 | |||
| 0e98e0b6d8 | |||
| f7431fd287 | |||
| 289caf3566 | |||
| 1e4e99ed4f | |||
| 5ab8e31792 | |||
| 725deec62e | |||
| b94f36708b | |||
| 86745f73a7 | |||
| 419b62e685 | |||
| 29a7ebbc13 | |||
| fd308b5c65 | |||
| 225e9b49d6 | |||
| 2b24cc18ff | |||
| 1b2ece1047 | |||
| 3fffa3a1a5 | |||
| 654e1efa2a | |||
| 99450b69de | |||
| 7b2aa2d1a4 | |||
| ecbd68aae8 | |||
| adc67270c4 | |||
| 5d30033c73 | |||
| ce51c25fb3 | |||
| 3e95bcc617 | |||
| 5738bc53ee | |||
| 82bb003fcd | |||
| 75f170191f | |||
| 6f5b6fbaab | |||
| feb3088148 | |||
| 7329cb6a46 | |||
| 51c4bad48c | |||
| 42af4127c2 | |||
| 7b38eeb324 | |||
| 867d0c0745 | |||
| c9c15c64e0 | |||
| 6de8e2452a | |||
| 5de6451692 | |||
| a9e6c9c41f | |||
| 47c8d321e3 | |||
| 8cb72385b3 | |||
| 3a980c19bf | |||
| 7ea3acccf3 | |||
| 340fb57bde | |||
| 5de8781894 | |||
| 325887fbac | |||
| 59f0fc1839 | |||
| 8501f24f2e | |||
| 795681b63f | |||
| 962b72b668 | |||
| 93e13a8041 | |||
| 84b0c6e443 | |||
| 4725c2bf1d | |||
| 492e0b5646 | |||
| 1bf3a84fa8 | |||
| 96797eff7a | |||
| 2c300bd1b5 | |||
| c25e9f11a2 | |||
| 342ff43418 | |||
| 65afe6e642 | |||
| f6c76cd373 | |||
| 98247d0ae9 | |||
| 925227526f | |||
| 10acc8417d | |||
| e1f1777848 | |||
| 0a46b0e7e2 | |||
| 105d52a082 | |||
| fa0828fa00 | |||
| bf27dabd7d | |||
| 9a09df6b9f | |||
| 9ecac33057 | |||
| a71cff0af4 | |||
| 74b488d6b5 | |||
| 0679058832 | |||
| 4e79deaadf | |||
| b071b0592f | |||
| e087497fdf | |||
| ae3ee5e171 | |||
| 6c0723a451 | |||
| 1c0881314a | |||
| 3d30ad6b13 | |||
| 09765986ab | |||
| 3a0220074b | |||
| e2b4671ab7 | |||
| 503fafc2f9 | |||
| b8ae32e043 | |||
| 9ad80eb4e3 | |||
| f44510e5ab | |||
| 0de22f6a26 | |||
| 1615e72b3a | |||
| 24a1a88f1e | |||
| 5878d2e8e2 | |||
| 2c9c4267b8 | |||
| 273dffbe20 | |||
| a29bb45705 | |||
| cc53414d90 | |||
| 6fd30a11d2 | |||
| 86c0b9f97d | |||
| 11c40ea0e1 | |||
| c451ddf0ee | |||
| 5935b2506f | |||
| 6c6439978a | |||
| cc60484bd8 | |||
| 51e9e89b47 | |||
| 2c41469899 | |||
| 8636f71a85 | |||
| 02b233c563 | |||
| fc211602ad | |||
| b6682b450c | |||
| 7ded67fa42 | |||
| fbbf52f12f | |||
| 9feb081430 | |||
| 7c53eac0ad | |||
| 49d8434231 | |||
| 189ee46453 | |||
| 59c3eb5376 | |||
| 4723e93063 | |||
| 8bb0fda6df | |||
| 5e8470faff | |||
| b742fc533f | |||
| d1f8f65870 | |||
| de53ea431e | |||
| cd16d8406c | |||
| abf1253b29 | |||
| 7a5cb7ba33 | |||
| 7799be5210 | |||
| 82e778d8d7 | |||
| 175b85e48d | |||
| 40cb7c6ba4 | |||
| a154ae5bb3 | |||
| 26b06607c7 | |||
| 5391894326 | |||
| a9c25dcc48 | |||
| 6240d8dec2 | |||
| 0ae2055ed1 | |||
| eb98cf558d | |||
| fe12eba098 | |||
| fa0be5f968 | |||
| 2a1bf9c27e | |||
| 060e4442b5 | |||
| 4309eaf1f7 | |||
| 530d13699b | |||
| 78af212661 | |||
| 6781626242 | |||
| c2d71a67ea | |||
| 25300b87d9 | |||
| 75f172be63 | |||
| 7e15ec568d | |||
| a8a028af57 | |||
| 2426826ebc | |||
| b1f588d74f | |||
| bfee59b12a | |||
| d016a0cc3c | |||
| fbff164add | |||
| 96e7617cbc | |||
| e970e3e5f9 | |||
| 07702512f4 | |||
| d07365e2cd | |||
| 7b2fa81b55 | |||
| 772d1cd04c | |||
| 3d63f86fbc | |||
| 54bf9b072d | |||
| bda41227d8 | |||
| 9c42cb38ac | |||
| b034b76077 | |||
| ed5f8cf141 | |||
| ae0dfdae9b | |||
| f033cb9cb6 | |||
| e7ad595eea | |||
| 4037eb19d4 | |||
| c5205056ba | |||
| cdd3549d27 | |||
| a55e80ab14 | |||
| 27b9fae681 | |||
| 71886e4f1b | |||
| 468da7c285 | |||
| c36b106668 | |||
| ea8b3d6660 | |||
| 65892feef6 | |||
| 10548f9512 | |||
| f5daf9accb | |||
| 7e525dcd8d | |||
| 4f7bcf53f4 | |||
| 8a445a2687 | |||
| d9a39767e3 | |||
| a3e52fbc15 | |||
| d10b249608 | |||
| e357eee8b6 | |||
| 2a3de130be | |||
| ac18e25d5d | |||
| 6d2d96dbc0 | |||
| 7f8ec2fd15 | |||
| abac0c76e7 | |||
| 4eefa8130f | |||
| af860eb623 | |||
| 8224e70aa0 | |||
| b6dea48d5e | |||
| 81a559fbbc | |||
| 6f1342e18b | |||
| c6417d63a2 | |||
| fcf49419d1 | |||
| cf94a9ebeb | |||
| 93bd53060c | |||
| c62d578537 | |||
| 79dd6f6b44 | |||
| 633099f72a | |||
| 9422b33d6f | |||
| 4f51703755 | |||
| d2be263333 | |||
| b7c480a93e | |||
| 47076d1d48 | |||
| a7f883dd5f | |||
| 783d40b5e0 | |||
| 6fb79721ff | |||
| d2ab3a2771 | |||
| 48be4c0ada | |||
| 94cb3ed880 | |||
| 055a005883 | |||
| b09e5585eb | |||
| 256fa3ecf6 | |||
| 2f4effcbc0 | |||
| 32c0b34c7b | |||
| af0727c4dd | |||
| a3c79af90d | |||
| f06d610f38 | |||
| 0b82524ef7 | |||
| 235574376d | |||
| 2cd2aae853 | |||
| 6438bb1dc9 | |||
| 2bd1df6691 | |||
| d5041555ff | |||
| 44e440d5a2 | |||
| d8160953aa | |||
| f313f0ba42 | |||
| 8d8ad4fc4e | |||
| 91a3862919 | |||
| 5070591660 | |||
| c61209d1cb | |||
| 0e30ec546c | |||
| 09d6dddb17 | |||
| 844e084ed1 | |||
| 3fd7e6914e | |||
| 082d702c3a | |||
| 7d928cbb6b | |||
| 89e2aa37f3 | |||
| be701aaad8 | |||
| c18afafd7e | |||
| f94dfbd262 | |||
| 534b1b1076 | |||
| 1dd5e0f3e7 | |||
| 5f6f6f6779 | |||
| 2350e84f5b | |||
| 0e8d6036b1 | |||
| 71b35fd976 | |||
| fcc46e4a85 | |||
| 64c06afaca | |||
| b818438be1 | |||
| 10967cd2f2 | |||
| d0b8b534b3 | |||
| 1b34539e65 | |||
| 79bc1c28ad | |||
| f2d19d8a3c | |||
| d38ae3dd0c | |||
| 1a566d6b1a | |||
| 68c0f5968a | |||
| fa170c9efb | |||
| c79b8c8bae | |||
| 19aa5326f7 | |||
| e754a0a431 | |||
| 79b590b1fa | |||
| 6e3efd3238 | |||
| c920943d3e |
@ -1,17 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*.js eol=lf
|
||||
*.yml eol=lf
|
||||
*.xml eol=lf
|
||||
14
.github/dependabot.yml
vendored
Normal file
14
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:09'
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:09'
|
||||
open-pull-requests-limit: 10
|
||||
28
.github/workflows/audit.yml
vendored
Normal file
28
.github/workflows/audit.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
name: Audit
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches-ignore:
|
||||
- 'dependabot/**'
|
||||
schedule:
|
||||
- cron: '09 22 * * *'
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
name: Audit
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '24.x'
|
||||
|
||||
- run: npm version
|
||||
- run: npm ci
|
||||
- run: npm audit
|
||||
10
.github/workflows/auto-approve.yml
vendored
Normal file
10
.github/workflows/auto-approve.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
name: Auto Approve
|
||||
|
||||
on:
|
||||
pull_request_target
|
||||
|
||||
jobs:
|
||||
auto-approve:
|
||||
uses: s4u/.github/.github/workflows/auto-approve.yml@master
|
||||
secrets:
|
||||
TECH_TOKEN: ${{ secrets.TECH_TOKEN }}
|
||||
13
.github/workflows/release-drafter.yml
vendored
Normal file
13
.github/workflows/release-drafter.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
name: Release Drafter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update_release_draft:
|
||||
name: Update Release Draft
|
||||
uses: s4u/.github/.github/workflows/release-drafter.yml@master
|
||||
24
.github/workflows/test.yml
vendored
24
.github/workflows/test.yml
vendored
@ -1,12 +1,15 @@
|
||||
name: "Test Action"
|
||||
name: Test
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches-ignore:
|
||||
- 'dependabot/**'
|
||||
schedule:
|
||||
- cron: '22 22 * * 5'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
@ -14,26 +17,31 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-node@v1
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '12.x'
|
||||
node-version: '24.x'
|
||||
|
||||
- uses: actions/setup-java@v1
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '1.8'
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
|
||||
- run: npm version
|
||||
- run: npm ci
|
||||
- run: npm audit
|
||||
- run: npm test
|
||||
|
||||
- uses: ./
|
||||
with:
|
||||
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
properties: '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
|
||||
apacheSnapshots: true
|
||||
sonatypeSnapshots: true
|
||||
oracleServers: '[{"id": "oServerId", "username": "oUsername", "password": "oPassword"}]'
|
||||
oracleRepo: true
|
||||
|
||||
- run: cat ~/.m2/settings.xml
|
||||
shell: bash
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@ node_modules/
|
||||
|
||||
# Editors
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# Logs
|
||||
logs
|
||||
|
||||
25
MAINTENANCE.md
Normal file
25
MAINTENANCE.md
Normal file
@ -0,0 +1,25 @@
|
||||
# update dependencies
|
||||
|
||||
npm update
|
||||
npm outdated
|
||||
|
||||
If new version exist put '*' in `package.json` and run again `npm update`
|
||||
|
||||
- new commit with dependency updates
|
||||
|
||||
# new release
|
||||
|
||||
- run - npm version patch -m "prepare release %s"
|
||||
or
|
||||
- run - npm version minor -m "prepare release %s"
|
||||
|
||||
- push commit
|
||||
|
||||
- checkout release/vX
|
||||
- merge master and push
|
||||
- run
|
||||
npm update
|
||||
npm install
|
||||
npm prune --production
|
||||
- commit and push "update dependency after merge from master"
|
||||
- git tag and git push --tags
|
||||
201
README.md
201
README.md
@ -1,67 +1,232 @@
|
||||
# maven-settings-action
|
||||
[](https://github.com/s4u/maven-settings-action/actions)
|
||||
[](https://github.com/s4u/maven-settings-action/actions?query=workflow%3ATest)
|
||||
[](https://github.com/s4u/maven-settings-action/actions?query=workflow%3AAudit)
|
||||
|
||||
This action setup maven environment for use in action by:
|
||||
|
||||
This action sets up Maven environments for use in GitHub Actions by:
|
||||
- create maven settings.xml
|
||||
- set ```interactiveMode``` to false - useful in CI system
|
||||
- after job finish generated settings.xml will be removed to prevent cache or left sensitive data on build system
|
||||
- add server to servers with id=github, username=$GITHUB_ACTOR and password=$GITHUB_TOKEN
|
||||
|
||||
# Contributions
|
||||
|
||||
- Contributions are welcome!
|
||||
- Give a star - if you want to encourage me to work on a project
|
||||
- Don't hesitate create issue
|
||||
- Give :star: - if you want to encourage me to work on a project
|
||||
- Don't hesitate to create issues for new features you dream of or if you suspect some bug
|
||||
|
||||
# Project versioning
|
||||
This project uses [Semantic Versioning](https://semver.org/).
|
||||
We recommended to use the latest and specific release version.
|
||||
|
||||
In order to keep your project dependencies up to date you can watch this repository *(Releases only)*
|
||||
or use automatic tools like [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates).
|
||||
|
||||
|
||||
# Usage
|
||||
|
||||
You can try our action [Setup Maven Action](https://github.com/marketplace/actions/setup-maven-action) for completely maven environment setup.
|
||||
|
||||
See [action.yml](action.yml)
|
||||
|
||||
Create default ```settings.xml```:
|
||||
## default ```settings.xml```
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.0
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
```
|
||||
|
||||
Create ```settings.xml``` with server section:
|
||||
## ```settings.xml``` with servers section
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.0
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
```
|
||||
|
||||
Create ```settings.xml``` with maven properties:
|
||||
Also you can use `path` argument if your settings.xml is stored in different location.
|
||||
|
||||
|
||||
All `server` attributes may be specified:
|
||||
* `id` _(required)_
|
||||
* `username`
|
||||
* `password`
|
||||
* `privateKey`
|
||||
* `passphrase`
|
||||
* `filePermissions`
|
||||
* `directoryPermissions`
|
||||
* `configuration`
|
||||
|
||||
Please refer to the [servers](http://maven.apache.org/settings.html#Servers) documentation for more information.
|
||||
|
||||
## ```settings.xml``` with servers section and additional configuration
|
||||
|
||||
``` yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
servers: |
|
||||
[{
|
||||
"id": "serverId",
|
||||
"configuration": {
|
||||
"item1": "value1",
|
||||
"item2": {
|
||||
"item21": "value21",
|
||||
"item22": "value22"
|
||||
}
|
||||
}
|
||||
}]
|
||||
```
|
||||
|
||||
result will be:
|
||||
|
||||
```xml
|
||||
<servers><server>
|
||||
<id>serverId</id>
|
||||
<configuration>
|
||||
<item1>value1</item1>
|
||||
<item2>
|
||||
<item21>value21</item21>
|
||||
<item22>value22</item22>
|
||||
</item1>
|
||||
</configuration>
|
||||
</server></servers>
|
||||
```
|
||||
|
||||
|
||||
## ```settings.xml``` with mirrors section
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.0
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
|
||||
```
|
||||
|
||||
## ```settings.xml``` with proxies section
|
||||
```yml
|
||||
step:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
proxies: '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost", "user": "proxUser", "password": "proxPassword"}]'
|
||||
```
|
||||
Note: Authentication details are optional.
|
||||
|
||||
## ```settings.xml``` with properties
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
||||
```
|
||||
|
||||
Create ```settings.xml``` with https://oss.sonatype.org/content/repositories/snapshots in repository list
|
||||
## ```settings.xml``` with https://central.sonatype.com/repository/maven-snapshots in repository list
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.0
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
sonatypeSnapshots: true
|
||||
```
|
||||
|
||||
Do not override existing ```settings.xml```, from version 2.0 file is override by default :
|
||||
## ```settings.xml``` with https://repository.apache.org/snapshots/ in repository list
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.0
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
apacheSnapshots: true
|
||||
```
|
||||
|
||||
## Do not override existing ```settings.xml```, from version **2.0** file is override by default :
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
override: false
|
||||
```
|
||||
|
||||
Do not add github to server in ```settings.xml```, by default is added:
|
||||
## Do not add github to server in ```settings.xml```, by default is added:
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.0
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
githubServer: false
|
||||
```
|
||||
|
||||
## ```settings.xml``` with special server item configuration for oracle repository [Oracle Maven Repository](https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9015)
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
oracleServers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
```
|
||||
|
||||
## ```settings.xml``` with [Oracle Maven Repository](https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9017)
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
oracleRepo: true
|
||||
```
|
||||
|
||||
## ```settings.xml``` with custom repositories
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
repositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||
```
|
||||
|
||||
## ```settings.xml``` with custom plugin repositories
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
pluginRepositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||
```
|
||||
|
||||
|
||||
## GitHub actions secrets
|
||||
|
||||
It is also possible pass in Github Secrets e.g.
|
||||
|
||||
``` yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
with:
|
||||
servers: |
|
||||
[{
|
||||
"id": "sonatype-nexus-snapshots",
|
||||
"username": "${{ secrets.SONATYPE_USERNAME }}",
|
||||
"password": "${{ secrets.SONATYPE_PASSWORD }}"
|
||||
}]
|
||||
```
|
||||
|
||||
**Note**: secrets are *not* passed in if the workflow is triggered from a forked repository. See [here](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#using-encrypted-secrets-in-a-workflow) for further information. This can be avoided by using `if` triggers on the job e.g. `if: github.event_name == 'push'`.
|
||||
|
||||
# Notes
|
||||
|
||||
**maven-settings-action** should be put at the latest position before maven run in order to avoid override ```setting.xml``` by another action
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: maven-
|
||||
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 8
|
||||
|
||||
- uses: s4u/maven-settings-action@v4.0.0
|
||||
|
||||
- run: mvn verify
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE).
|
||||
|
||||
35
action.yml
35
action.yml
@ -1,4 +1,4 @@
|
||||
name: 'maven-setings-action'
|
||||
name: 'maven-settings-action'
|
||||
description: 'Prepare maven settings.xml'
|
||||
|
||||
branding:
|
||||
@ -6,9 +6,17 @@ branding:
|
||||
color: 'green'
|
||||
|
||||
inputs:
|
||||
servers:
|
||||
description: 'servers definition in joson array, eg: [{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
path:
|
||||
description: 'override default path to settings.xml which is $HOME/.m2/settings.xml'
|
||||
required: false
|
||||
servers:
|
||||
description: 'servers definition in json array, eg: [{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
required: false
|
||||
mirrors:
|
||||
description: 'mirrors definition in json array, eg: [{"id": "id", "name": "name", "mirrorOf": "mirrorOf", "url": "url"}]'
|
||||
required: false
|
||||
proxies:
|
||||
description: 'proxies definition in json array, eg: [{"id": "id", "active": "active", "protocol": "protocol", "host": "hostl", "port": "port", "nonProxyHosts", "nonProxyHosts"}]'
|
||||
properties:
|
||||
description: 'json array with properties, eg [{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
||||
required: false
|
||||
@ -16,6 +24,10 @@ inputs:
|
||||
description: 'add https://oss.sonatype.org/content/repositories/snapshots to repository list - true or false'
|
||||
default: "false"
|
||||
required: false
|
||||
apacheSnapshots:
|
||||
description: 'add https://repository.apache.org/snapshots to repository list - true or false'
|
||||
default: "false"
|
||||
required: false
|
||||
override:
|
||||
description: 'override existing settings.xml file'
|
||||
default: "true"
|
||||
@ -24,10 +36,21 @@ inputs:
|
||||
description: 'add to settings.xml servers server-id: github; username=$GITHUB_ACTOR and password=$GITHUB_TOKEN'
|
||||
default: "true"
|
||||
required: false
|
||||
|
||||
|
||||
oracleServers:
|
||||
description: 'servers definition in json array, eg: [{"id": "serverId", "username": "username", "password": "password"}] for Oracle repository'
|
||||
required: false
|
||||
oracleRepo:
|
||||
description: 'add Oracle Maven Repository'
|
||||
default: "false"
|
||||
required: false
|
||||
repositories:
|
||||
description: 'list of custom repositories as json array, e.g: [{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||
required: false
|
||||
pluginRepositories:
|
||||
description: 'list of custom plugin repositories as json array, e.g: [{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node24'
|
||||
main: 'index.js'
|
||||
post: 'cleanup.js'
|
||||
|
||||
@ -49,12 +49,12 @@ afterAll(() => {
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmdirSync(testHomePath);
|
||||
fs.rmSync(testHomePath, { recursive: true });
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('run with default values', () => {
|
||||
cp.execSync(`node ${cleanupPath}`, { env: process.env }).toString();
|
||||
cp.spawnSync('node', [ `${cleanupPath}` ], { env: process.env }).toString();
|
||||
})
|
||||
|
||||
29
eslint.config.mjs
Normal file
29
eslint.config.mjs
Normal file
@ -0,0 +1,29 @@
|
||||
import globals from "globals";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import js from "@eslint/js";
|
||||
import { FlatCompat } from "@eslint/eslintrc";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname,
|
||||
recommendedConfig: js.configs.recommended,
|
||||
allConfig: js.configs.all
|
||||
});
|
||||
|
||||
export default [...compat.extends("eslint:recommended"), {
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.commonjs,
|
||||
...globals.node,
|
||||
Atomics: "readonly",
|
||||
SharedArrayBuffer: "readonly",
|
||||
},
|
||||
|
||||
ecmaVersion: 2018,
|
||||
sourceType: "commonjs",
|
||||
},
|
||||
|
||||
rules: {},
|
||||
}];
|
||||
190
index.test.js
190
index.test.js
@ -55,7 +55,7 @@ afterAll(() => {
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmdirSync(testHomePath);
|
||||
fs.rmSync(testHomePath, { recursive: true });
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
@ -63,18 +63,192 @@ afterAll(() => {
|
||||
|
||||
test('run with all feature', () => {
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "serverId", "username": "sUsername", "password": "sPassword", "configuration": {"props1": "value1"}}]';
|
||||
process.env['INPUT_ORACLESERVERS'] = '[{"id": "oServerId", "username": "oUsername", "password": "oPassword"}]';
|
||||
process.env['INPUT_GITHUBSERVER'] = true;
|
||||
|
||||
process.env['INPUT_MIRRORS'] = '[{"id": "mirrorId", "name": "mirror Name", "mirrorOf": "mirror Off *", "url": "mirror url"}]';
|
||||
process.env['INPUT_PROXIES'] = '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost"}]';
|
||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
process.env['INPUT_SONATYPESNAPSHOT'] = true;
|
||||
|
||||
cp.execSync(`node ${indexPath}`, { env: process.env }).toString();
|
||||
process.env['INPUT_APACHESNAPSHOTS'] = true;
|
||||
process.env['INPUT_SONATYPESNAPSHOTS'] = true;
|
||||
process.env['INPUT_ORACLEREPO'] = true;
|
||||
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||
process.env['INPUT_PLUGINREPOSITORIES'] = '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
|
||||
|
||||
cp.spawnSync('node', [ `${indexPath}` ], { env: process.env, stdio: 'inherit' });
|
||||
const settingsStatus = fs.lstatSync(settingsPath);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
|
||||
const settingsBody = fs.readFileSync(settingsPath).toString();
|
||||
expect(settingsBody).toMatch('<settings>');
|
||||
expect(settingsBody).toMatch('<servers><server><id>serverId</id><username>username</username><password>password</password></server></servers>');
|
||||
expect(settingsBody).toMatch('prop1');
|
||||
const settingsBody = fs.readFileSync(settingsPath).toString().replace(/^\s*$(?:\r\n?|\n)/gm, '');
|
||||
expect(settingsBody).toBe(`<settings>
|
||||
<interactiveMode>false</interactiveMode>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>_properties_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties><prop1>value1</prop1><prop2>value2</prop2></properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>_apache-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>apache.snapshots.https</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snapshots.https</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>_sonatype-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>central-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>_maven.oracle.com_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven.oracle.com</id>
|
||||
<url>https://maven.oracle.com</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven.oracle.com</id>
|
||||
<url>https://maven.oracle.com</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>_custom_repositories_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories> <repository>
|
||||
<id>repoId</id>
|
||||
<name>repoName</name>
|
||||
<url>url</url>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</repository></repositories>
|
||||
<pluginRepositories> <pluginRepository>
|
||||
<id>repoId</id>
|
||||
<name>repoName</name>
|
||||
<url>url</url>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</pluginRepository></pluginRepositories>
|
||||
</profile></profiles>
|
||||
<servers>
|
||||
<server>
|
||||
<id>serverId</id>
|
||||
<username>sUsername</username>
|
||||
<password>sPassword</password>
|
||||
<configuration><props1>value1</props1></configuration>
|
||||
</server>
|
||||
<server>
|
||||
<id>oServerId</id>
|
||||
<username>oUsername</username>
|
||||
<password>oPassword</password>
|
||||
<configuration>
|
||||
<basicAuthScope>
|
||||
<host>ANY</host>
|
||||
<port>ANY</port>
|
||||
<realm>OAM 11g</realm>
|
||||
</basicAuthScope>
|
||||
<httpConfiguration>
|
||||
<all>
|
||||
<params>
|
||||
<property>
|
||||
<name>http.protocol.allow-circular-redirects</name>
|
||||
<value>%b,true</value>
|
||||
</property>
|
||||
</params>
|
||||
</all>
|
||||
</httpConfiguration>
|
||||
</configuration>
|
||||
</server>
|
||||
<server>
|
||||
<id>github</id>
|
||||
<username>\${env.GITHUB_ACTOR}</username>
|
||||
<password>\${env.GITHUB_TOKEN}</password>
|
||||
</server></servers>
|
||||
<mirrors>
|
||||
<mirror>
|
||||
<id>mirrorId</id>
|
||||
<name>mirror Name</name>
|
||||
<mirrorOf>mirror Off *</mirrorOf>
|
||||
<url>mirror url</url>
|
||||
</mirror></mirrors>
|
||||
<proxies><proxy>
|
||||
<id>proxyId</id>
|
||||
<active>isActive</active>
|
||||
<protocol>proxyProtocol</protocol>
|
||||
<host>proxyHost</host>
|
||||
<port>proxyPort</port>
|
||||
<nonProxyHosts>nonProxyHost</nonProxyHosts>
|
||||
</proxy></proxies>
|
||||
</settings>`);
|
||||
})
|
||||
|
||||
11102
package-lock.json
generated
11102
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@ -1,11 +1,13 @@
|
||||
{
|
||||
"name": "maven-settings-action",
|
||||
"version": "1.0.0",
|
||||
"version": "4.0.0",
|
||||
"description": "Prepare maven settings",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint index.js settings.js",
|
||||
"test": "eslint index.js settings.js && jest --coverage"
|
||||
"test": "eslint index.js settings.js && jest --coverage",
|
||||
"version": "./update-readme.sh",
|
||||
"postversion": "git tag --delete v$npm_new_version"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -24,12 +26,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/s4u/maven-settings-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.3",
|
||||
"xmldom": "^0.3.0",
|
||||
"xpath": "0.0.27"
|
||||
"@actions/core": "^2.0.3",
|
||||
"@xmldom/xmldom": "^0.8.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.1.0"
|
||||
"eslint": "^9.39.1",
|
||||
"jest": "^30.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
292
settings.js
292
settings.js
@ -26,17 +26,20 @@ const core = require('@actions/core');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const DOMParser = require('xmldom').DOMParser;
|
||||
const XMLSerializer = require('xmldom').XMLSerializer;
|
||||
const xpath = require('xpath');
|
||||
|
||||
const DOMParser = require('@xmldom/xmldom').DOMParser;
|
||||
const XMLSerializer = require('@xmldom/xmldom').XMLSerializer;
|
||||
|
||||
function getSettingsPath() {
|
||||
return path.join(os.homedir(), '.m2', 'settings.xml');
|
||||
const _path = core.getInput('path');
|
||||
if (!_path) {
|
||||
return path.join(os.homedir(), '.m2', 'settings.xml');
|
||||
} else {
|
||||
return _path;
|
||||
}
|
||||
}
|
||||
|
||||
function getSettingsTemplate() {
|
||||
const templatePath = path.join(__dirname, 'templates', 'settings.xml');
|
||||
function getTemplate(templateName) {
|
||||
const templatePath = path.join(__dirname, 'templates', templateName);
|
||||
const templateStr = fs.readFileSync(templatePath).toString();
|
||||
return new DOMParser().parseFromString(templateStr, 'text/xml');
|
||||
}
|
||||
@ -52,43 +55,205 @@ function writeSettings(settingsPath, templateXml) {
|
||||
fs.writeFileSync(settingsPath, settingStr);
|
||||
}
|
||||
|
||||
function createElementWithText(template, tag, text) {
|
||||
const tagXml = template.createElement(tag);
|
||||
tagXml.textContent = text;
|
||||
return tagXml;
|
||||
function jsonToXml(templateXml, xmlTag, json) {
|
||||
for (const key in json) {
|
||||
const keyXml = templateXml.createElement(key);
|
||||
const value = json[key];
|
||||
if (value instanceof Object) {
|
||||
jsonToXml(templateXml, keyXml, value);
|
||||
} else {
|
||||
keyXml.textContent = value;
|
||||
}
|
||||
xmlTag.appendChild(keyXml);
|
||||
}
|
||||
}
|
||||
|
||||
function fillServer(template, id, username, password) {
|
||||
function fillServer(templateXml, templateName, id, username, password, privateKey, passphrase, filePermissions, directoryPermissions, configurations) {
|
||||
|
||||
const serverXml = template.createElement('server');
|
||||
|
||||
if (!id || !username || !password) {
|
||||
core.setFailed('servers must contain id, username and password');
|
||||
if (!id || (!username && !configurations)) {
|
||||
core.setFailed(templateName + ' must contain id, and username or configuration');
|
||||
return;
|
||||
}
|
||||
|
||||
const idXml = createElementWithText(template, 'id', id);
|
||||
serverXml.appendChild(idXml);
|
||||
const serverXml = getTemplate(templateName + '.xml')
|
||||
serverXml.getElementsByTagName('id')[0].textContent = id;
|
||||
|
||||
const usernameXml = createElementWithText(template, 'username', username);
|
||||
serverXml.appendChild(usernameXml);
|
||||
const serverTags = {
|
||||
'username': username,
|
||||
'password': password,
|
||||
'privateKey': privateKey,
|
||||
'passphrase': passphrase,
|
||||
'filePermissions': filePermissions,
|
||||
'directoryPermissions': directoryPermissions
|
||||
};
|
||||
for (const tag in serverTags) {
|
||||
const serverTag = serverXml.getElementsByTagName(tag)[0];
|
||||
const tagValue = serverTags[tag];
|
||||
if (tagValue) {
|
||||
serverTag.textContent = tagValue;
|
||||
} else {
|
||||
serverXml.documentElement.removeChild(serverTag);
|
||||
}
|
||||
}
|
||||
|
||||
const passwordXml = createElementWithText(template, 'password', password);
|
||||
serverXml.appendChild(passwordXml);
|
||||
const configurationTag = serverXml.getElementsByTagName('configuration')[0];
|
||||
if (configurations) {
|
||||
jsonToXml(templateXml, configurationTag, configurations);
|
||||
} else {
|
||||
if (configurationTag.childNodes.length == 0) {
|
||||
serverXml.documentElement.removeChild(configurationTag);
|
||||
}
|
||||
}
|
||||
|
||||
const serversXml = template.getElementsByTagName('servers')[0];
|
||||
const serversXml = templateXml.getElementsByTagName('servers')[0];
|
||||
serversXml.appendChild(serverXml);
|
||||
}
|
||||
|
||||
function fillServers(template) {
|
||||
function fillServers(template, templateName) {
|
||||
|
||||
const servers = core.getInput('servers');
|
||||
const servers = core.getInput(templateName);
|
||||
|
||||
if (!servers) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSON.parse(servers).forEach((server) => fillServer(template, server.id, server.username, server.password));
|
||||
JSON.parse(servers).forEach((server) =>
|
||||
fillServer(template, templateName, server.id, server.username,
|
||||
server.password, server.privateKey, server.passphrase,
|
||||
server.filePermissions, server.directoryPermissions,
|
||||
server.configuration));
|
||||
}
|
||||
|
||||
function fillRepository(templateXml, templateName, id, name, url, releases, snapshots) {
|
||||
|
||||
if (!id || !url) {
|
||||
core.setFailed(templateName + ' must contain id and url');
|
||||
return;
|
||||
}
|
||||
|
||||
const repositoryXml = getTemplate(templateName + '.xml')
|
||||
repositoryXml.getElementsByTagName('id')[0].textContent = id;
|
||||
|
||||
const repositoryTags = {
|
||||
'name': name,
|
||||
'url': url
|
||||
};
|
||||
for (const tag in repositoryTags) {
|
||||
const repositoryTag = repositoryXml.getElementsByTagName(tag)[0];
|
||||
const tagValue = repositoryTags[tag];
|
||||
if (tagValue) {
|
||||
repositoryTag.textContent = tagValue;
|
||||
} else {
|
||||
repositoryXml.documentElement.removeChild(repositoryTag);
|
||||
}
|
||||
}
|
||||
|
||||
const additionalTags = {
|
||||
'releases': releases,
|
||||
'snapshots': snapshots
|
||||
};
|
||||
for (const tag in additionalTags) {
|
||||
const repositoryTag = repositoryXml.getElementsByTagName(tag)[0];
|
||||
const tagValue = additionalTags[tag];
|
||||
if (tagValue) {
|
||||
jsonToXml(templateXml, repositoryTag, tagValue);
|
||||
} else {
|
||||
repositoryXml.documentElement.removeChild(repositoryTag);
|
||||
}
|
||||
}
|
||||
|
||||
const repositoriesXml = templateXml.getElementsByTagName(templateName)[0];
|
||||
repositoriesXml.appendChild(repositoryXml);
|
||||
}
|
||||
|
||||
function fillRepositories(template) {
|
||||
|
||||
const repositories = core.getInput('repositories');
|
||||
const pluginRepositories = core.getInput('pluginRepositories');
|
||||
|
||||
if (!repositories && !pluginRepositories) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const customRepositoriesTemplate = getTemplate('custom-repositories.xml');
|
||||
const profilesXml = template.getElementsByTagName('profiles')[0];
|
||||
profilesXml.appendChild(customRepositoriesTemplate);
|
||||
|
||||
if (repositories) {
|
||||
JSON.parse(repositories).forEach((repository) =>
|
||||
fillRepository(customRepositoriesTemplate, 'repositories',
|
||||
repository.id, repository.name, repository.url, repository.releases, repository.snapshots));
|
||||
}
|
||||
if (pluginRepositories) {
|
||||
JSON.parse(pluginRepositories).forEach((repository) =>
|
||||
fillRepository(customRepositoriesTemplate, 'pluginRepositories',
|
||||
repository.id, repository.name, repository.url, repository.releases, repository.snapshots));
|
||||
}
|
||||
}
|
||||
|
||||
function fillMirror(template, id, name, mirrorOf, url) {
|
||||
|
||||
if (!id || !name || !mirrorOf || !url) {
|
||||
core.setFailed('mirrors must contain id, name, mirrorOf and url');
|
||||
return;
|
||||
}
|
||||
|
||||
const mirrorXml = getTemplate('mirrors.xml');
|
||||
mirrorXml.getElementsByTagName('id')[0].textContent = id;
|
||||
mirrorXml.getElementsByTagName('name')[0].textContent = name;
|
||||
mirrorXml.getElementsByTagName('mirrorOf')[0].textContent = mirrorOf;
|
||||
mirrorXml.getElementsByTagName('url')[0].textContent = url;
|
||||
|
||||
const mirrorsXml = template.getElementsByTagName('mirrors')[0];
|
||||
mirrorsXml.appendChild(mirrorXml);
|
||||
}
|
||||
|
||||
function fillMirrors(template) {
|
||||
|
||||
const mirrors = core.getInput('mirrors');
|
||||
|
||||
if (!mirrors) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSON.parse(mirrors).forEach((mirror) => fillMirror(template, mirror.id, mirror.name, mirror.mirrorOf, mirror.url));
|
||||
}
|
||||
|
||||
function fillProxies(template) {
|
||||
|
||||
const proxies = core.getInput('proxies');
|
||||
|
||||
if (!proxies) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSON.parse(proxies).forEach((proxy) => fillProxy(template, proxy.id, proxy.active, proxy.protocol, proxy.host, proxy.port, proxy.nonProxyHosts, proxy.user, proxy.password));
|
||||
}
|
||||
|
||||
function fillProxy(template, id, active, protocol, host, port, nonProxyHosts, proxyUser, proxyPassword) {
|
||||
if(!id || !active || !protocol || !host || !port || !nonProxyHosts) {
|
||||
core.setFailed('proxies must contain id, active, protocol, host, port and nonProxyHosts');
|
||||
return;
|
||||
}
|
||||
|
||||
const proxyXml = getTemplate('proxy.xml');
|
||||
proxyXml.getElementsByTagName("id")[0].textContent = id;
|
||||
proxyXml.getElementsByTagName("active")[0].textContent = active;
|
||||
proxyXml.getElementsByTagName("protocol")[0].textContent = protocol;
|
||||
proxyXml.getElementsByTagName("host")[0].textContent = host;
|
||||
proxyXml.getElementsByTagName("port")[0].textContent = port;
|
||||
proxyXml.getElementsByTagName("nonProxyHosts")[0].textContent = nonProxyHosts;
|
||||
|
||||
if(proxyUser) {
|
||||
jsonToXml(proxyXml, proxyXml.documentElement, {username: proxyUser});
|
||||
}
|
||||
if(proxyPassword) {
|
||||
jsonToXml(proxyXml, proxyXml.documentElement, {password: proxyPassword});
|
||||
}
|
||||
|
||||
const proxiesXml = template.getElementsByTagName('proxies')[0];
|
||||
proxiesXml.appendChild(proxyXml);
|
||||
}
|
||||
|
||||
function isInputTrue(inputName) {
|
||||
@ -102,42 +267,54 @@ function fillServerForGithub(templateXml) {
|
||||
return;
|
||||
}
|
||||
|
||||
fillServer(templateXml, 'github', '${env.GITHUB_ACTOR}', '${env.GITHUB_TOKEN}');
|
||||
}
|
||||
|
||||
function activateProfile(template, profileId) {
|
||||
const activeByDefault = xpath
|
||||
.select(`/settings/profiles/profile[id[contains(text(),"${profileId}")]]/activation/activeByDefault`, template);
|
||||
|
||||
if (activeByDefault) {
|
||||
activeByDefault[0].textContent = 'true';
|
||||
}
|
||||
fillServer(templateXml, 'servers', 'github', '${env.GITHUB_ACTOR}', '${env.GITHUB_TOKEN}');
|
||||
}
|
||||
|
||||
function fillProperties(template) {
|
||||
|
||||
const properties = core.getInput('properties');
|
||||
|
||||
if (!properties) {
|
||||
return;
|
||||
}
|
||||
|
||||
activateProfile(template, '_properties_')
|
||||
const propertiesXml = xpath
|
||||
.select(`/settings/profiles/profile[id[contains(text(),"_properties_")]]/properties`, template)[0];
|
||||
const propertiesProfileXml = getTemplate('properties.xml');
|
||||
const propertiesXml = propertiesProfileXml.getElementsByTagName('properties')[0];
|
||||
|
||||
JSON.parse(properties).forEach((property) => {
|
||||
|
||||
for (const key in property) {
|
||||
const keyXml = template.createElement(key);
|
||||
keyXml.textContent = property[key];
|
||||
propertiesXml.appendChild(keyXml);
|
||||
}
|
||||
});
|
||||
|
||||
const profilesXml = template.getElementsByTagName('profiles')[0];
|
||||
profilesXml.appendChild(propertiesProfileXml);
|
||||
|
||||
}
|
||||
|
||||
function addProfile(template, profileName) {
|
||||
const sonatypeXml = getTemplate(profileName);
|
||||
const profilesXml = template.getElementsByTagName('profiles')[0];
|
||||
profilesXml.appendChild(sonatypeXml);
|
||||
}
|
||||
|
||||
function addApacheSnapshots(template) {
|
||||
if (isInputTrue('apacheSnapshots')) {
|
||||
addProfile(template, 'apache-snapshot.xml')
|
||||
}
|
||||
}
|
||||
|
||||
function addSonatypeSnapshots(template) {
|
||||
if (isInputTrue('sonatypeSnapshots')) {
|
||||
activateProfile(template, '_sonatype-snapshots_')
|
||||
addProfile(template, 'sonatype-snapshot.xml')
|
||||
}
|
||||
}
|
||||
|
||||
function addOracleRepo(template) {
|
||||
if (isInputTrue('oracleRepo')) {
|
||||
addProfile(template, 'oracle-repo.xml')
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +322,7 @@ function generate() {
|
||||
|
||||
const settingsPath = getSettingsPath();
|
||||
|
||||
core.info('Prepare maven setings: ' + settingsPath);
|
||||
core.info('Prepare maven settings: ' + settingsPath);
|
||||
|
||||
if (fs.existsSync(settingsPath)) {
|
||||
if (isInputTrue('override')) {
|
||||
@ -156,12 +333,18 @@ function generate() {
|
||||
}
|
||||
}
|
||||
|
||||
const templateXml = getSettingsTemplate();
|
||||
fillServers(templateXml);
|
||||
fillServerForGithub(templateXml);
|
||||
fillProperties(templateXml);
|
||||
addSonatypeSnapshots(templateXml);
|
||||
writeSettings(settingsPath, templateXml);
|
||||
const settingsXml = getTemplate('settings.xml');
|
||||
fillProxies(settingsXml);
|
||||
fillMirrors(settingsXml);
|
||||
fillServers(settingsXml, 'servers');
|
||||
fillServers(settingsXml, 'oracleServers');
|
||||
fillServerForGithub(settingsXml);
|
||||
fillProperties(settingsXml);
|
||||
addApacheSnapshots(settingsXml);
|
||||
addSonatypeSnapshots(settingsXml);
|
||||
addOracleRepo(settingsXml);
|
||||
fillRepositories(settingsXml)
|
||||
writeSettings(settingsPath, settingsXml);
|
||||
core.saveState('maven-settings', 'ok');
|
||||
}
|
||||
|
||||
@ -172,22 +355,27 @@ function cleanup() {
|
||||
if (mavenSettingsState == 'ok') {
|
||||
if (fs.existsSync(settingsPath)) {
|
||||
fs.unlinkSync(settingsPath);
|
||||
core.info('Cleanup maven setings: ' + settingsPath + ' - file was removed');
|
||||
core.info('Cleanup maven settings: ' + settingsPath + ' - file was removed');
|
||||
} else {
|
||||
core.warning('Cleanup maven setings: ' + settingsPath + ' - file not exist');
|
||||
core.warning('Cleanup maven settings: ' + settingsPath + ' - file not exist');
|
||||
}
|
||||
} else {
|
||||
core.info('Cleanup maven setings: ' + settingsPath + ' - file wasn\'t generated by action');
|
||||
core.info('Cleanup maven settings: ' + settingsPath + ' - file wasn\'t generated by action');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSettingsTemplate,
|
||||
getTemplate,
|
||||
writeSettings,
|
||||
fillMirrors,
|
||||
fillServers,
|
||||
fillProxies,
|
||||
fillServerForGithub,
|
||||
fillProperties,
|
||||
fillRepositories,
|
||||
addApacheSnapshots,
|
||||
addSonatypeSnapshots,
|
||||
addOracleRepo,
|
||||
generate,
|
||||
cleanup
|
||||
}
|
||||
|
||||
704
settings.test.js
704
settings.test.js
@ -24,8 +24,8 @@ THE SOFTWARE.
|
||||
|
||||
const os = require('os');
|
||||
const process = require('process');
|
||||
const DOMParser = require('xmldom').DOMParser;
|
||||
const XMLSerializer = require('xmldom').XMLSerializer;
|
||||
const DOMParser = require('@xmldom/xmldom').DOMParser;
|
||||
const XMLSerializer = require('@xmldom/xmldom').XMLSerializer;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
@ -38,6 +38,14 @@ const settingsPath = path.join(testHomePath, '.m2', 'settings.xml');
|
||||
|
||||
var consoleOutput = [];
|
||||
|
||||
function stringAsXml(str) {
|
||||
return new DOMParser().parseFromString(str, 'text/xml');
|
||||
}
|
||||
|
||||
function xmlAsString(xml) {
|
||||
return new XMLSerializer().serializeToString(xml).replace(/^\s*$(?:\r\n?|\n)/gm, '');
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
if (!fs.existsSync(testHomePath)) {
|
||||
fs.mkdirSync(testHomePath);
|
||||
@ -51,7 +59,7 @@ beforeAll(() => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
xmlTestProfile = new DOMParser().parseFromString(`<settings>
|
||||
xmlTestProfile = stringAsXml(`<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>_properties_</id>
|
||||
@ -79,7 +87,7 @@ afterAll(() => {
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmdirSync(testHomePath);
|
||||
fs.rmSync(testHomePath, { recursive: true });
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
@ -99,8 +107,7 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
test('template should be read', () => {
|
||||
|
||||
const template = settings.getSettingsTemplate();
|
||||
const template = settings.getTemplate('settings.xml');
|
||||
|
||||
expect(template).toBeDefined();
|
||||
});
|
||||
@ -120,9 +127,9 @@ test('xml should be write', () => {
|
||||
|
||||
test('fillServers do nothing if no params', () => {
|
||||
|
||||
const xml = new DOMParser().parseFromString("<servers/>");
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
settings.fillServers(xml);
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
@ -131,119 +138,544 @@ test('fillServers do nothing if no params', () => {
|
||||
|
||||
test('fillServers one server', () => {
|
||||
|
||||
const xml = new DOMParser().parseFromString("<servers/>");
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "id1", "username": "username1", "password":"password1"}]';
|
||||
|
||||
settings.fillServers(xml);
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<username>username1</username>
|
||||
<password>password1</password>
|
||||
</server></servers>`);
|
||||
|
||||
expect(xmlStr).toBe("<servers>" +
|
||||
"<server><id>id1</id><username>username1</username><password>password1</password></server>" +
|
||||
"</servers>");
|
||||
});
|
||||
|
||||
test('fillServers with username and configuration', () => {
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "id1", "username": "username", "configuration": {"prop1": "prop1Value", "prop2": "prop2Value"}}]';
|
||||
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<username>username</username>
|
||||
<configuration><prop1>prop1Value</prop1><prop2>prop2Value</prop2></configuration>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers with username, password and configuration', () => {
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "id1", "username": "username", "password": "password", "configuration": {"prop1": "prop1Value", "prop2": "prop2Value"}}]';
|
||||
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<username>username</username>
|
||||
<password>password</password>
|
||||
<configuration><prop1>prop1Value</prop1><prop2>prop2Value</prop2></configuration>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers with username, privateKey', () => {
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "id1", "username": "username", "privateKey": "${user.home}/.ssh/id_rsa"}]';
|
||||
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<username>username</username>
|
||||
<privateKey>\${user.home}/.ssh/id_rsa</privateKey>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers with username, privateKey, and passphrase', () => {
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "id1", "username": "username", "privateKey": "${user.home}/.ssh/id_rsa", "passphrase": "secret"}]';
|
||||
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<username>username</username>
|
||||
<privateKey>\${user.home}/.ssh/id_rsa</privateKey>
|
||||
<passphrase>secret</passphrase>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers with all attributes', () => {
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "server001", "username": "my_login", "password": "my_password", "privateKey": "${user.home}/.ssh/id_dsa", "passphrase": "some_passphrase", "filePermissions": "664", "directoryPermissions": "775", "configuration": {"prop1": "prop1Value", "prop2": "prop2Value"} }]';
|
||||
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>server001</id>
|
||||
<username>my_login</username>
|
||||
<password>my_password</password>
|
||||
<privateKey>\${user.home}/.ssh/id_dsa</privateKey>
|
||||
<passphrase>some_passphrase</passphrase>
|
||||
<filePermissions>664</filePermissions>
|
||||
<directoryPermissions>775</directoryPermissions>
|
||||
<configuration><prop1>prop1Value</prop1><prop2>prop2Value</prop2></configuration>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers with configuration', () => {
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "id1", "configuration": {"prop1": "prop1Value", "prop2": "prop2Value"}}]';
|
||||
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<configuration><prop1>prop1Value</prop1><prop2>prop2Value</prop2></configuration>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers with configuration subLevel', () => {
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "id1", "configuration": {"prop1": {"prop11": "value11", "prop12": "value12"}, "prop2": "value2"}}]';
|
||||
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<configuration><prop1><prop11>value11</prop11><prop12>value12</prop12></prop1><prop2>value2</prop2></configuration>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers two servers', () => {
|
||||
|
||||
const xml = new DOMParser().parseFromString("<servers/>");
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "id1", "username": "username1", "password":"password1"},\
|
||||
{"id": "id2", "username": "username2", "password":"password2"}]';
|
||||
|
||||
settings.fillServers(xml);
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe("<servers>" +
|
||||
"<server><id>id1</id><username>username1</username><password>password1</password></server>" +
|
||||
"<server><id>id2</id><username>username2</username><password>password2</password></server>" +
|
||||
"</servers>");
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<username>username1</username>
|
||||
<password>password1</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>id2</id>
|
||||
<username>username2</username>
|
||||
<password>password2</password>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers incorrect fields', () => {
|
||||
test('fill servers incorrect fields', () => {
|
||||
|
||||
const xml = new DOMParser().parseFromString("<servers/>");
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"idx": "id1"}]';
|
||||
|
||||
settings.fillServers(xml);
|
||||
settings.fillServers(xml, 'servers');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe('<servers/>');
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/::error::servers must contain id, username and password/)
|
||||
expect.stringMatching(/::error::servers must contain id, and username or configuration/)
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
test('fill oracleServers', () => {
|
||||
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_ORACLESERVERS'] = '[{"id": "id1", "username": "username1", "password":"password1"}]';
|
||||
|
||||
settings.fillServers(xml, 'oracleServers');
|
||||
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>id1</id>
|
||||
<username>username1</username>
|
||||
<password>password1</password>
|
||||
<configuration>
|
||||
<basicAuthScope>
|
||||
<host>ANY</host>
|
||||
<port>ANY</port>
|
||||
<realm>OAM 11g</realm>
|
||||
</basicAuthScope>
|
||||
<httpConfiguration>
|
||||
<all>
|
||||
<params>
|
||||
<property>
|
||||
<name>http.protocol.allow-circular-redirects</name>
|
||||
<value>%b,true</value>
|
||||
</property>
|
||||
</params>
|
||||
</all>
|
||||
</httpConfiguration>
|
||||
</configuration>
|
||||
</server></servers>`);
|
||||
});
|
||||
|
||||
test('fillServers github', () => {
|
||||
|
||||
const xml = new DOMParser().parseFromString("<servers/>");
|
||||
const xml = stringAsXml("<servers/>");
|
||||
|
||||
process.env['INPUT_GITHUBSERVER'] = 'true';
|
||||
|
||||
settings.fillServerForGithub(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe('<servers><server><id>github</id><username>${env.GITHUB_ACTOR}</username><password>${env.GITHUB_TOKEN}</password></server></servers>');
|
||||
expect(xmlAsString(xml)).toBe(`<servers>
|
||||
<server>
|
||||
<id>github</id>
|
||||
<username>\${env.GITHUB_ACTOR}</username>
|
||||
<password>\${env.GITHUB_TOKEN}</password>
|
||||
</server></servers>`);
|
||||
expect(consoleOutput).toEqual([]);
|
||||
});
|
||||
|
||||
test('addSonatypeSnapshots activate', () => {
|
||||
test('fillMirrors do nothing if no params', () => {
|
||||
|
||||
const xml = stringAsXml("<mirrors/>");
|
||||
|
||||
settings.fillMirrors(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe("<mirrors/>");
|
||||
expect(consoleOutput).toEqual([]);
|
||||
});
|
||||
|
||||
test('fillMirrors one mirror', () => {
|
||||
|
||||
const xml = stringAsXml("<mirrors/>");
|
||||
|
||||
process.env['INPUT_MIRRORS'] = '[{"id": "id1", "name": "name", "mirrorOf":"mirrorOf", "url":"url"}]';
|
||||
|
||||
settings.fillMirrors(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe(`<mirrors>
|
||||
<mirror>
|
||||
<id>id1</id>
|
||||
<name>name</name>
|
||||
<mirrorOf>mirrorOf</mirrorOf>
|
||||
<url>url</url>
|
||||
</mirror></mirrors>`);
|
||||
expect(consoleOutput).toEqual([]);
|
||||
});
|
||||
|
||||
test('fillMirrors two mirrors', () => {
|
||||
|
||||
const xml = stringAsXml("<mirrors/>");
|
||||
|
||||
process.env['INPUT_MIRRORS'] = '[{"id": "id1", "name": "name1", "mirrorOf":"mirrorOf1", "url":"url1"},{"id": "id2", "name": "name2", "mirrorOf":"mirrorOf2", "url":"url2"}]';
|
||||
|
||||
settings.fillMirrors(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe(`<mirrors>
|
||||
<mirror>
|
||||
<id>id1</id>
|
||||
<name>name1</name>
|
||||
<mirrorOf>mirrorOf1</mirrorOf>
|
||||
<url>url1</url>
|
||||
</mirror>
|
||||
<mirror>
|
||||
<id>id2</id>
|
||||
<name>name2</name>
|
||||
<mirrorOf>mirrorOf2</mirrorOf>
|
||||
<url>url2</url>
|
||||
</mirror></mirrors>`);
|
||||
expect(consoleOutput).toEqual([]);
|
||||
});
|
||||
|
||||
test('fillMirrors incorrect fields', () => {
|
||||
|
||||
const xml = stringAsXml("<mirrors/>");
|
||||
|
||||
process.env['INPUT_MIRRORS'] = '[{"idx": "id1"}]';
|
||||
|
||||
settings.fillMirrors(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe('<mirrors/>');
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/::error::mirrors must contain id, name, mirrorOf and url/)
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
test("fillProxies do noting if no params", () => {
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe("<proxies/>");
|
||||
expect(consoleOutput).toEqual([]);
|
||||
})
|
||||
|
||||
test("fillProxies one proxy", () => {
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
process.env['INPUT_PROXIES'] = `[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol",
|
||||
"host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost"}]`;
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<proxies><proxy>
|
||||
<id>proxyId</id>
|
||||
<active>isActive</active>
|
||||
<protocol>proxyProtocol</protocol>
|
||||
<host>proxyHost</host>
|
||||
<port>proxyPort</port>
|
||||
<nonProxyHosts>nonProxyHost</nonProxyHosts>
|
||||
</proxy></proxies>`)
|
||||
|
||||
})
|
||||
|
||||
test("fillProxies one proxy with auth info", () => {
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
process.env['INPUT_PROXIES'] = `[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol",
|
||||
"host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost", "user": "proxyUser", "password": "somepassword"}]`;
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<proxies><proxy>
|
||||
<id>proxyId</id>
|
||||
<active>isActive</active>
|
||||
<protocol>proxyProtocol</protocol>
|
||||
<host>proxyHost</host>
|
||||
<port>proxyPort</port>
|
||||
<nonProxyHosts>nonProxyHost</nonProxyHosts>
|
||||
<username>proxyUser</username><password>somepassword</password></proxy></proxies>`)
|
||||
|
||||
})
|
||||
|
||||
test("fillProxies two proxies", () => {
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
process.env['INPUT_PROXIES'] = `[{"id": "proxyId1", "active": "isActive1", "protocol": "proxyProtocol1",
|
||||
"host": "proxyHost1", "port": "proxyPort1", "nonProxyHosts": "nonProxyHost1"},
|
||||
{"id": "proxyId2", "active": "isActive2", "protocol": "proxyProtocol2",
|
||||
"host": "proxyHost2", "port": "proxyPort2", "nonProxyHosts": "nonProxyHost2"}]`;
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<proxies><proxy>
|
||||
<id>proxyId1</id>
|
||||
<active>isActive1</active>
|
||||
<protocol>proxyProtocol1</protocol>
|
||||
<host>proxyHost1</host>
|
||||
<port>proxyPort1</port>
|
||||
<nonProxyHosts>nonProxyHost1</nonProxyHosts>
|
||||
</proxy><proxy>
|
||||
<id>proxyId2</id>
|
||||
<active>isActive2</active>
|
||||
<protocol>proxyProtocol2</protocol>
|
||||
<host>proxyHost2</host>
|
||||
<port>proxyPort2</port>
|
||||
<nonProxyHosts>nonProxyHost2</nonProxyHosts>
|
||||
</proxy></proxies>`)
|
||||
|
||||
})
|
||||
|
||||
test('fillProxies incorrect fields', () => {
|
||||
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
process.env['INPUT_PROXIES'] = '[{"idx": "id1"}]';
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe('<proxies/>');
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/::error::proxies must contain id, active, protocol, host, port and nonProxyHosts/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('addApacheSnapshots', () => {
|
||||
|
||||
process.env['INPUT_APACHESNAPSHOTS'] = "true";
|
||||
|
||||
const xml = stringAsXml('<profiles/>');
|
||||
|
||||
settings.addApacheSnapshots(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<profiles>
|
||||
<profile>
|
||||
<id>_apache-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>apache.snapshots.https</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snapshots.https</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile></profiles>`);
|
||||
});
|
||||
|
||||
test('addSonatypeSnapshots', () => {
|
||||
|
||||
process.env['INPUT_SONATYPESNAPSHOTS'] = "true";
|
||||
|
||||
settings.addSonatypeSnapshots(xmlTestProfile);
|
||||
const xml = stringAsXml('<profiles/>');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xmlTestProfile);
|
||||
expect(xmlStr).toBe(`<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>_properties_</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<properties/>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>_sonatype-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
</profiles>
|
||||
</settings>`);
|
||||
settings.addSonatypeSnapshots(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<profiles>
|
||||
<profile>
|
||||
<id>_sonatype-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>central-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile></profiles>`);
|
||||
});
|
||||
|
||||
test('addOracleRepo', () => {
|
||||
|
||||
process.env['INPUT_ORACLEREPO'] = "true";
|
||||
|
||||
const xml = stringAsXml('<profiles/>');
|
||||
|
||||
settings.addOracleRepo(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<profiles>
|
||||
<profile>
|
||||
<id>_maven.oracle.com_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven.oracle.com</id>
|
||||
<url>https://maven.oracle.com</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven.oracle.com</id>
|
||||
<url>https://maven.oracle.com</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile></profiles>`);
|
||||
});
|
||||
|
||||
test('fillProperties', () => {
|
||||
|
||||
process.env['INPUT_PROPERTIES'] = '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]';
|
||||
|
||||
settings.fillProperties(xmlTestProfile);
|
||||
const xml = stringAsXml('<profiles/>');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xmlTestProfile);
|
||||
expect(xmlStr).toBe(`<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>_properties_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties><propertyName1>propertyValue1</propertyName1><propertyName2>propertyValue2</propertyName2></properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>_sonatype-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
</profiles>
|
||||
</settings>`);
|
||||
settings.fillProperties(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<profiles>
|
||||
<profile>
|
||||
<id>_properties_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties><propertyName1>propertyValue1</propertyName1><propertyName2>propertyValue2</propertyName2></properties>
|
||||
</profile></profiles>`);
|
||||
})
|
||||
|
||||
test('fillProperties do nothing if no params', () => {
|
||||
@ -276,7 +708,7 @@ test('cleanup - not generated', () => {
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file wasn\'t generated by action/)
|
||||
expect.stringMatching(/Cleanup maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file wasn\'t generated by action/)
|
||||
])
|
||||
);
|
||||
})
|
||||
@ -289,7 +721,7 @@ test('cleanup - not exist', () => {
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/::warning::Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file not exist/)
|
||||
expect.stringMatching(/::warning::Cleanup maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file not exist/)
|
||||
])
|
||||
);
|
||||
})
|
||||
@ -303,13 +735,13 @@ test('cleanup - ok', () => {
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file was removed/)
|
||||
expect.stringMatching(/Cleanup maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file was removed/)
|
||||
])
|
||||
);
|
||||
expect(fs.existsSync(settingsPath)).not.toBeTruthy();
|
||||
})
|
||||
|
||||
test('genereate', () => {
|
||||
test('generate', () => {
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
@ -319,13 +751,13 @@ test('genereate', () => {
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/Prepare maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/:save-state name=maven-settings::ok/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('genereate - skip', () => {
|
||||
test('generate - skip', () => {
|
||||
|
||||
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
||||
|
||||
@ -333,13 +765,13 @@ test('genereate - skip', () => {
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/Prepare maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/::warning::maven settings.xml already exists - skip/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('genereate - override', () => {
|
||||
test('generate - override', () => {
|
||||
|
||||
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
||||
process.env['INPUT_OVERRIDE'] = 'true';
|
||||
@ -348,9 +780,123 @@ test('genereate - override', () => {
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/Prepare maven settings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/maven settings.xml already exists - override/),
|
||||
expect.stringMatching(/:save-state name=maven-settings::ok/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('generate - custom path', () => {
|
||||
|
||||
if (!fs.existsSync(testHomePath)) {
|
||||
fs.mkdirSync(testHomePath);
|
||||
}
|
||||
|
||||
const mySettings = path.join(testHomePath, 'settings_custom.xml');
|
||||
process.env['INPUT_PATH'] = mySettings;
|
||||
settings.generate();
|
||||
|
||||
const settingsStatus = fs.lstatSync(mySettings);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('addCustomRepositories - one with snapshots one without', () => {
|
||||
|
||||
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}},{"id":"repoId2","url":"url2"}]'
|
||||
|
||||
const xml = stringAsXml('<profiles/>');
|
||||
|
||||
settings.fillRepositories(xml,'repositories');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<profiles>
|
||||
<profile>
|
||||
<id>_custom_repositories_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories> <repository>
|
||||
<id>repoId</id>
|
||||
<name>repoName</name>
|
||||
<url>url</url>
|
||||
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</repository> <repository>
|
||||
<id>repoId2</id>
|
||||
|
||||
<url>url2</url>
|
||||
|
||||
|
||||
</repository></repositories>
|
||||
<pluginRepositories/>
|
||||
</profile></profiles>`);
|
||||
});
|
||||
|
||||
test('addCustomPluginRepositories - one with releases and snapshots one without', () => {
|
||||
|
||||
process.env['INPUT_PLUGINREPOSITORIES'] = `
|
||||
[{"id":"repoId",
|
||||
"name":"repoName",
|
||||
"url":"url",
|
||||
"releases":{"enabled":false},
|
||||
"snapshots":{"enabled":true}
|
||||
},{
|
||||
"id":"repoId2",
|
||||
"url":"url2"
|
||||
}]`
|
||||
|
||||
const xml = stringAsXml('<profiles/>');
|
||||
|
||||
settings.fillRepositories(xml,'pluginRepositories');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<profiles>
|
||||
<profile>
|
||||
<id>_custom_repositories_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories/>
|
||||
<pluginRepositories> <pluginRepository>
|
||||
<id>repoId</id>
|
||||
<name>repoName</name>
|
||||
<url>url</url>
|
||||
<releases><enabled>false</enabled></releases>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</pluginRepository> <pluginRepository>
|
||||
<id>repoId2</id>
|
||||
|
||||
<url>url2</url>
|
||||
|
||||
|
||||
</pluginRepository></pluginRepositories>
|
||||
</profile></profiles>`);
|
||||
});
|
||||
|
||||
test('addCustomRepositories - fail if url is missing', () => {
|
||||
|
||||
process.env['INPUT_REPOSITORIES'] = '[{"id":"repoId","name":"repoName"}]'
|
||||
|
||||
const xml = stringAsXml('<profiles/>');
|
||||
|
||||
settings.fillRepositories(xml,'repositories');
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe(`<profiles>
|
||||
<profile>
|
||||
<id>_custom_repositories_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories/>
|
||||
<pluginRepositories/>
|
||||
</profile></profiles>`);
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/::error::repositories must contain id and url/)
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
31
templates/apache-snapshot.xml
Normal file
31
templates/apache-snapshot.xml
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
<profile>
|
||||
<id>_apache-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>apache.snapshots.https</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snapshots.https</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
9
templates/custom-repositories.xml
Normal file
9
templates/custom-repositories.xml
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
<profile>
|
||||
<id>_custom_repositories_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories/>
|
||||
<pluginRepositories/>
|
||||
</profile>
|
||||
7
templates/mirrors.xml
Normal file
7
templates/mirrors.xml
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
<mirror>
|
||||
<id/>
|
||||
<name/>
|
||||
<mirrorOf/>
|
||||
<url/>
|
||||
</mirror>
|
||||
31
templates/oracle-repo.xml
Normal file
31
templates/oracle-repo.xml
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
<profile>
|
||||
<id>_maven.oracle.com_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven.oracle.com</id>
|
||||
<url>https://maven.oracle.com</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven.oracle.com</id>
|
||||
<url>https://maven.oracle.com</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
27
templates/oracleServers.xml
Normal file
27
templates/oracleServers.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<server>
|
||||
<id />
|
||||
<username />
|
||||
<password />
|
||||
<privateKey />
|
||||
<passphrase />
|
||||
<filePermissions />
|
||||
<directoryPermissions />
|
||||
<configuration>
|
||||
<basicAuthScope>
|
||||
<host>ANY</host>
|
||||
<port>ANY</port>
|
||||
<realm>OAM 11g</realm>
|
||||
</basicAuthScope>
|
||||
<httpConfiguration>
|
||||
<all>
|
||||
<params>
|
||||
<property>
|
||||
<name>http.protocol.allow-circular-redirects</name>
|
||||
<value>%b,true</value>
|
||||
</property>
|
||||
</params>
|
||||
</all>
|
||||
</httpConfiguration>
|
||||
</configuration>
|
||||
</server>
|
||||
7
templates/pluginRepositories.xml
Normal file
7
templates/pluginRepositories.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<pluginRepository>
|
||||
<id/>
|
||||
<name/>
|
||||
<url/>
|
||||
<releases/>
|
||||
<snapshots/>
|
||||
</pluginRepository>
|
||||
8
templates/properties.xml
Normal file
8
templates/properties.xml
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
<profile>
|
||||
<id>_properties_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties />
|
||||
</profile>
|
||||
8
templates/proxy.xml
Normal file
8
templates/proxy.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<proxy>
|
||||
<id />
|
||||
<active />
|
||||
<protocol />
|
||||
<host />
|
||||
<port />
|
||||
<nonProxyHosts />
|
||||
</proxy>
|
||||
7
templates/repositories.xml
Normal file
7
templates/repositories.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<repository>
|
||||
<id/>
|
||||
<name/>
|
||||
<url/>
|
||||
<releases/>
|
||||
<snapshots/>
|
||||
</repository>
|
||||
11
templates/servers.xml
Normal file
11
templates/servers.xml
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
<server>
|
||||
<id />
|
||||
<username />
|
||||
<password />
|
||||
<privateKey />
|
||||
<passphrase />
|
||||
<filePermissions />
|
||||
<directoryPermissions />
|
||||
<configuration />
|
||||
</server>
|
||||
@ -1,48 +1,7 @@
|
||||
<settings>
|
||||
|
||||
<interactiveMode>false</interactiveMode>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>_properties_</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<properties />
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>_sonatype-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
<profiles/>
|
||||
<servers />
|
||||
<mirrors />
|
||||
<proxies />
|
||||
</settings>
|
||||
|
||||
31
templates/sonatype-snapshot.xml
Normal file
31
templates/sonatype-snapshot.xml
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
<profile>
|
||||
<id>_sonatype-snapshots_</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>central-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
9
update-readme.sh
Executable file
9
update-readme.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "old_version: $npm_old_version"
|
||||
echo "new_version: $npm_new_version"
|
||||
echo "package_name: $npm_package_name"
|
||||
|
||||
sed -i '' "s/$npm_package_name@v$npm_old_version/$npm_package_name@v$npm_new_version/g" README.md
|
||||
|
||||
git add README.md
|
||||
Reference in New Issue
Block a user