1
1
package io.jenkins.plugins.gitlabserverconfig.servers.GitLabServer
2
2
3
- import hudson.Util
4
- import hudson.util.Secret
5
3
import io.jenkins.plugins.gitlabserverconfig.servers.GitLabServer
6
4
import lib.CredentialsTagLib
7
5
import lib.FormTagLib
8
- import java.security.SecureRandom
9
6
import org.apache.commons.lang.RandomStringUtils ;
10
7
11
- byte [] random = new byte [16 ]; // 16x8=128bit worth of randomness, since we use md5 digest as the API token
12
- SecureRandom RANDOM = new SecureRandom ();
13
- RANDOM . nextBytes(random);
14
- Secret token = Secret . decrypt(Util . toHexString(random));
15
-
16
8
def f = namespace(FormTagLib )
17
9
def c = namespace(CredentialsTagLib )
18
10
19
- String secretTextId = RandomStringUtils . randomNumeric(4 )
20
- String genButtonId = RandomStringUtils . randomNumeric(4 )
21
-
22
11
f. entry(title : _(" Display Name" ), field : " name" , " description" : " A unique name for the server" ) {
23
12
f. textbox(default : String . format(" gitlab-%s" , RandomStringUtils . randomNumeric(GitLabServer . SHORT_NAME_LENGTH )))
24
13
}
@@ -40,22 +29,7 @@ f.entry(title: _("System Hook"), field: "manageSystemHooks", "description": "Do
40
29
}
41
30
42
31
f. entry(title : _(" Secret Token" ), field : " secretToken" , " description" : " The secret token used while setting up hook url in the GitLab server" ) {
43
- f. password(id : secretTextId)
44
- }
45
-
46
- f. entry(field : " genButton" ) {
47
- raw("""
48
- <button id="${ genButtonId} ">
49
- Generate Secret Token
50
- </button>
51
- <script>
52
- document.getElementById("${ genButtonId} ").addEventListener('click', function(e) {
53
- e.preventDefault();
54
- console.log("${ token} ")
55
- document.getElementById("${ secretTextId} ").value = ${ token} ;
56
- });
57
- </script>
58
- """ )
32
+ f. password()
59
33
}
60
34
61
35
f. entry(title : _(" Root URL for hooks" ), field : " hooksRootUrl" , " description" : " Jenkins root URL to use in hooks URL (if different from the public Jenkins root URL)" ) {
0 commit comments