Skip to content

Commit

Permalink
Fix issue with spryker jenkins-runner running as root user
Browse files Browse the repository at this point in the history
  • Loading branch information
andytson-inviqa committed Apr 29, 2022
1 parent c206bcc commit 5d0e270
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
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
}
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

0 comments on commit 5d0e270

Please sign in to comment.