-
Notifications
You must be signed in to change notification settings - Fork 18
/
importDockerProject.sh
executable file
·64 lines (52 loc) · 2.21 KB
/
importDockerProject.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
#!/bin/bash
set -e
# Add common variables.
source ~/ci/config
source ~/ci/config.default
# Create demo project on Gerrit.
curl --request PUT --user "${GERRIT_ADMIN_UID}:${GERRIT_ADMIN_PWD}" -d@- --header "Content-Type: application/json;charset=UTF-8" ${GERRIT_WEBURL}/a/projects/demo-docker < ~/ci/demoProject.json
# Setup local git.
rm -rf ~/ci/demo-docker
mkdir ~/ci/demo-docker
git init ~/ci/demo-docker
cd ~/ci/demo-docker
#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-docker
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 ~/ci/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
cp -R ~/ci/dockerProject .
git add dockerProject
git commit -m "Init project"
git push origin
#stop ssh agent
kill ${SSH_AGENT_PID}
# Remove local git repository.
cd -
rm -rf ~/ci/demo-docker
# Create job in Jenkins
DEMO_DOCKER_CONFIG_XML=$(source ~/ci/jenkins.demo-docker.config.xml.sh)
curl --request POST --user "${GERRIT_ADMIN_UID}:${GERRIT_ADMIN_PWD}" --data-raw "${DEMO_DOCKER_CONFIG_XML}" --header "Content-Type: application/xml;charset=UTF-8" ${JENKINS_WEBURL}/createItem?name=demo-docker
# 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 ~/jenkins-slave-docker/createJenkinsSlave.sh