forked from openfrontier/ci
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathimportDemoProject.sh
executable file
·66 lines (52 loc) · 2.11 KB
/
importDemoProject.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
BASEDIR=$(readlink -f $(dirname $0))
SCRIPT_DIR=./img-scripts
set -e
# Add common variables.
source ${BASEDIR}/config
source ${BASEDIR}/config.default
# Create demo project on Gerrit.
curl -X PUT --user ${GERRIT_ADMIN_UID}:${GERRIT_ADMIN_PWD} -d@- --header "Content-Type: application/json;charset=UTF-8" ${GERRIT_WEBURL}/a/projects/demo < ${BASEDIR}/demoProject.json
# Setup local git.
rm -rf ${BASEDIR}/demo
mkdir ${BASEDIR}/demo
git init ${BASEDIR}/demo
cd ${BASEDIR}/demo
#start ssh agent and add ssh key
eval $(ssh-agent)
ssh-add "${SSH_KEY_PATH}"
git config core.filemode false
git config user.name ${GERRIT_ADMIN_UID}
git config user.email ${GERRIT_ADMIN_EMAIL}
git config push.default simple
git remote add origin ssh://${GERRIT_ADMIN_UID}@${GERRIT_SSH_HOST}:29418/demo
git fetch -q origin
git fetch -q origin refs/meta/config:refs/remotes/origin/meta/config
# Setup project access right.
## Registered users can change everything since it's just a demo project.
git checkout meta/config
cp ${BASEDIR}/groups .
git config -f project.config --add access.refs/*.owner "group Registered Users"
git config -f project.config --add access.refs/*.read "group Registered Users"
git add groups project.config
git commit -m "Add access right to Registered Users."
git push origin meta/config:meta/config
# Import demoProject
git checkout master
tar xf ${BASEDIR}/demoProject.tar
git add demo
git commit -m "Init project"
git push origin
#stop ssh agent
kill ${SSH_AGENT_PID}
# Remove local git repository.
cd -
rm -rf ${BASEDIR}/demo
curl -X POST -d@- --header "Content-Type: application/xml;charset=UTF-8" ${JENKINS_WEBURL}/createItem?name=demo < ${BASEDIR}/jenkins.config.xml
# Import redmine demo data
REDMINE_DEMO_DATA_SQL=redmine-init-demo.sql
docker exec pg-redmine gosu postgres psql -d redmine -U redmine -f /${REDMINE_DEMO_DATA_SQL}
# Non member add roles
docker exec pg-redmine gosu postgres psql -d redmine -U redmine -c "update roles set permissions = '---\n- :view_issues\n- :add_issues\n- :view_changesets\n' where id = 1"
# Create jenkins slave docker volume.
source ${SCRIPT_DIR}/jenkins-slave-docker/createJenkinsSlave.sh