2014-05-02 01:05:15 +00:00
|
|
|
# Jenkins Account Management/Sign-up App
|
2016-01-07 21:31:02 +00:00
|
|
|
|
2014-05-02 01:05:15 +00:00
|
|
|
## Testing locally
|
2016-01-07 21:31:02 +00:00
|
|
|
|
|
|
|
First, set up a tunnel to Jenkins LDAP server. Run the following command and
|
|
|
|
keep the terminal open:
|
2012-12-22 17:33:07 +00:00
|
|
|
|
2017-05-04 14:44:48 +00:00
|
|
|
ssh -4 -L 9389:localhost:389 ldap.jenkins.io
|
2012-12-22 17:33:07 +00:00
|
|
|
|
2016-01-07 21:31:02 +00:00
|
|
|
Create `config.properties` in the same directory as `pom.xml`. See the
|
|
|
|
`Parameters` class for the details, but it should look something like the
|
|
|
|
following:
|
2012-12-22 17:33:07 +00:00
|
|
|
|
|
|
|
server=ldap://localhost:9389/
|
|
|
|
managerDN=cn=admin,dc=jenkins-ci,dc=org
|
|
|
|
newUserBaseDN=ou=people,dc=jenkins-ci,dc=org
|
|
|
|
smtpServer=localhost
|
|
|
|
managerPassword=*****
|
2015-12-15 18:36:13 +00:00
|
|
|
circuitBreakerFile=./circuitBreaker.txt
|
|
|
|
url=http://localhost:8080/account/
|
2012-12-22 17:33:07 +00:00
|
|
|
|
|
|
|
Finally, run the application with Jetty, then access `http://localhost:8080/`:
|
|
|
|
|
2016-06-15 05:23:34 +00:00
|
|
|
./gradlew -Djira.url=https://issues.jenkins-ci.org/ -Djira.username=kohsuke -Djira.password=... -Durl=ldap://localhost:9389 -Dpassword=... jettyRun
|
2012-12-22 17:33:07 +00:00
|
|
|
|
2016-01-07 21:31:02 +00:00
|
|
|
(As you can see above, this connects your test instance to the actual LDAP
|
|
|
|
server, so the data you'll be seeing is real.
|
2014-05-01 18:16:21 +00:00
|
|
|
|
2016-06-15 05:23:34 +00:00
|
|
|
The command line system properties are for JIRA LDAP sync tool. JIRA user account you are providing has to have the system admin access to JIRA.
|
|
|
|
TODO: feed this data from config.properties
|
|
|
|
|
2017-04-24 13:04:34 +00:00
|
|
|
### Docker Compose
|
|
|
|
A docker compose file can be used for testing purpose.
|
|
|
|
|
|
|
|
_Require ssh tunnel to an ldap server and an WAR archive_
|
|
|
|
|
|
|
|
* Create the file ```.env``` used by docker-compose to load configuration
|
|
|
|
.env example
|
|
|
|
```
|
2017-05-09 15:22:40 +00:00
|
|
|
APP_URL=http://localhost:8080/
|
|
|
|
ELECTION_CANDIDATES=alice,bob
|
|
|
|
ELECTION_CLOSE=2038/01/19
|
|
|
|
ELECTION_OPEN=1970/01/01
|
2017-04-24 13:04:34 +00:00
|
|
|
JIRA_USERNAME=<insert your jira username>
|
|
|
|
JIRA_PASSWORD=<insert your jira password>
|
|
|
|
JIRA_URL=https://issues.jenkins-ci.org
|
2017-05-09 15:22:40 +00:00
|
|
|
LDAP_URL=server=ldap://localhost:9389/
|
|
|
|
LDAP_PASSWORD=<insert your ldap password>
|
2017-04-24 13:04:34 +00:00
|
|
|
LDAP_MANAGER_DN=cn=admin,dc=jenkins-ci,dc=org
|
|
|
|
LDAP_NEW_USER_BASE_DN=ou=people,dc=jenkins-ci,dc=org
|
2017-05-09 15:22:40 +00:00
|
|
|
RECAPTCHA_PRIVATE_KEY=recaptcha_private_key
|
|
|
|
RECAPTCHA_PUBLIC_KEY=recaptcha_public_key
|
2017-06-02 13:17:53 +00:00
|
|
|
SMTP_SERVER=smtp.jenkins.io
|
|
|
|
SMTP_USER=user@jenkins.io
|
|
|
|
SMTP_AUTH=true
|
|
|
|
SMTP_PASSWORD=password
|
2017-04-24 13:04:34 +00:00
|
|
|
```
|
|
|
|
* Run docker-compose
|
|
|
|
```docker-compose up --build accountapp```
|
2014-05-01 18:16:21 +00:00
|
|
|
|
2014-05-02 01:05:15 +00:00
|
|
|
## Packaging
|
2014-05-01 18:16:21 +00:00
|
|
|
|
2016-01-07 21:31:02 +00:00
|
|
|
For deploying to production, this app gets containerized. The container expects
|
2017-04-24 13:04:34 +00:00
|
|
|
to see `/etc/accountapp` mounted from outside that contains the above mentioned
|
2016-01-07 21:31:02 +00:00
|
|
|
`config.properties`
|
2016-03-23 03:31:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
To run the container locally, build it then:
|
|
|
|
|
|
|
|
docker run -ti --net=host -v `pwd`:/etc/accountapp jenkinsciinfra/account-app:latest
|
2017-04-24 13:04:34 +00:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
Instead of mounting the configuration file from an external volume,
|
|
|
|
we may want to use environment variable.
|
|
|
|
|
|
|
|
**Those two options are mutually exclusive.**
|
|
|
|
|
|
|
|
```
|
|
|
|
* APP_URL
|
|
|
|
* CIRCUIT_BREAKER_FILE
|
2017-05-09 15:22:40 +00:00
|
|
|
* ELECTION_CANDIDATES coma separated list of candidates
|
|
|
|
* ELECTION_CLOSE date election will close. yyyy/MM/dd
|
|
|
|
* ELECTION_OPEN date election will open. yyyy/MM/dd
|
|
|
|
* ELECTION_LOGDIR
|
2017-04-24 13:04:34 +00:00
|
|
|
* JIRA_PASSWORD
|
|
|
|
* JIRA_URL
|
|
|
|
* JIRA_USERNAME
|
|
|
|
* LDAP_MANAGER_DN
|
|
|
|
* LDAP_NEW_USER_BASE_DN
|
|
|
|
* LDAP_PASSWORD
|
|
|
|
* LDAP_URL
|
|
|
|
* RECAPTCHA_PUBLIC_KEY
|
|
|
|
* RECAPTCHA_PRIVATE_KEY
|
|
|
|
* SMTP_SERVER
|
2017-06-02 13:17:53 +00:00
|
|
|
* SMTP_USER
|
|
|
|
* SMTP_PASSWORD
|
|
|
|
* SMTP_AUTH
|
2017-04-24 13:04:34 +00:00
|
|
|
```
|
2017-05-09 15:22:40 +00:00
|
|
|
|
|
|
|
## Makefile
|
|
|
|
|
|
|
|
``` make build```: Build build/libs/accountapp-2.5.war and docker image
|
|
|
|
``` make run ```: Run docker container
|
|
|
|
``` make clean ```: Clean build environment
|
2017-06-02 13:17:53 +00:00
|
|
|
|
|
|
|
## SMTP
|
|
|
|
The accountapp support different types of SMTP configuration to send emails.
|
|
|
|
* Nothing is configured, the application try to connect on localhost:25
|
|
|
|
* SMTP_AUTH is set to false, the accountapp will connect on $SMTP_SERVER:25
|
|
|
|
* SMTP_AUTH is set to true, the accountapp will connect on $SMTP_SERVER:587 with tls authentication
|
|
|
|
and will use username: $SMTP_USER with password $SMTP_PASSWORD.
|