-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with spryker jenkins-runner running as root user
- Loading branch information
1 parent
c206bcc
commit 5d0e270
Showing
2 changed files
with
32 additions
and
20 deletions.
There are no files selected for viewing
21 changes: 1 addition & 20 deletions
21
src/spryker/docker/image/jenkins-runner/root/lib/task/jenkins/start.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,6 @@ | ||
#!/bin/bash | ||
|
||
function _trap_jenkins_exit() | ||
{ | ||
echo 'Terminating jenkins agent' >&2 | ||
local CHILD_PIDS | ||
mapfile -t CHILD_PIDS < <(jobs -p) | ||
kill -TERM "${CHILD_PIDS[@]}" | ||
wait | ||
app jenkins unregister | ||
} | ||
|
||
function task_jenkins_start() | ||
{ | ||
local -r JENKINS_RUNNER_NAME=$(hostname) | ||
|
||
trap _trap_jenkins_exit EXIT | ||
|
||
app jenkins:register | ||
|
||
java -jar /usr/local/bin/jenkins-cli.jar -s "$JENKINS_URL" offline-node "" | ||
java -jar /usr/local/bin/jenkins-slave.jar -jnlpUrl "$JENKINS_URL/computer/$JENKINS_RUNNER_NAME/slave-agent.jnlp" & | ||
|
||
wait | ||
exec su -s /usr/local/bin/jenkins-agent-start.sh www-data > /proc/1/fd/1 2> /proc/1/fd/2 | ||
} |
31 changes: 31 additions & 0 deletions
31
src/spryker/docker/image/jenkins-runner/root/usr/local/bin/jenkins-agent-start.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
function _trap_jenkins_exit() | ||
{ | ||
echo 'Terminating jenkins agent' >&2 | ||
local CHILD_PIDS | ||
mapfile -t CHILD_PIDS < <(jobs -p) | ||
kill -TERM "${CHILD_PIDS[@]}" | ||
wait | ||
app jenkins unregister | ||
} | ||
|
||
function start() | ||
{ | ||
local -r JENKINS_RUNNER_NAME=$(hostname) | ||
|
||
trap _trap_jenkins_exit EXIT | ||
|
||
app jenkins:register | ||
|
||
java -jar /usr/local/bin/jenkins-cli.jar -s "$JENKINS_URL" offline-node "" | ||
java -jar /usr/local/bin/jenkins-slave.jar -jnlpUrl "$JENKINS_URL/computer/$JENKINS_RUNNER_NAME/slave-agent.jnlp" & | ||
|
||
wait | ||
} | ||
|
||
start |