Skip to content

Commit f554e3a

Browse files
committed
add coding.net token support
1 parent a4d02c9 commit f554e3a

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ deploy:
5757
[repo_name]:
5858
url: <repository url>
5959
branch: [branch]
60+
token: [token]
61+
token_name: [token_name] # for coding.net
6062
```
6163
6264
- **repo**: Repository settings, or plain url of your repo
@@ -66,6 +68,7 @@ deploy:
6668
- Defaults to `coding-pages` on Coding.net.
6769
- Otherwise defaults to `master`.
6870
- **token**: Optional token value to authenticate with the repo. Prefix with `$` to read token from environment variable (recommended). Repo must be a http(s) url. [More details](#deploy-with-token).
71+
- **token_name** coding.net needs token name and token to authenticate. [More details](#deploy-with-token)
6972
- **repo_name**: Unique name when deploying to multiple repositories.
7073
* Example:
7174
``` yaml
@@ -111,6 +114,7 @@ While this plugin can parse authentication token from the config, only use this
111114
Additional guides:
112115

113116
- Create a GitHub Personal Access Token. [[Link]](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line)
117+
- Create a Coding Project Access Token. [[Link]](https://help.coding.net/docs/project/features/deploy-tokens.html)
114118
- Add authentication token to Travis CI. [[Link]](https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings)
115119

116120
## How it works

lib/parse_config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { URL } = require('url');
77
function parseObjRepo(repo) {
88
let url = repo.url;
99
let branch = repo.branch;
10+
let token_name = repo.token_name;
1011
let configToken = repo.token;
1112

1213
if (!branch) {
@@ -30,7 +31,12 @@ function parseObjRepo(repo) {
3031
} else {
3132
userToken = configToken;
3233
}
33-
repoUrl.username = userToken;
34+
if (token_name && repoUrl.host === 'e.coding.net') {
35+
repoUrl.username = token_name;
36+
repoUrl.password = userToken;
37+
} else {
38+
repoUrl.username = userToken;
39+
}
3440
url = repoUrl.href;
3541
}
3642
}

0 commit comments

Comments
 (0)