Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring start-slave script on MacOS inline with other OSes #780

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manifests/slave.pp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
mode => '0755',
owner => 'root',
group => 'wheel',
notify => Service['jenkins-slave'],
}

file { '/Library/LaunchDaemons/org.jenkins-ci.slave.jnlp.plist':
Expand Down
68 changes: 66 additions & 2 deletions templates/start-slave.sh.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,68 @@
#!/usr/bin/env bash

source <%= @defaults_location %>/jenkins-slave
java -jar <%= @slave_home %>/<%= @client_jar %> $JENKINS_SLAVE_ARGS
source <%= @defaults_location %>/jenkins-slave

# mandatory input vars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of cut'n'pasting the the entire jenkins-slave-run script, how about installing it and call it from this script?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good plan.
I think I did it this way because it wasn't an exact copy of the linux script.
I will see if I can reuse the linux script.

[[ -x "$JAVA" ]] || (fail "$JAVA is not executable")
[[ -f "$JENKINS_SLAVE_JAR" ]] || (fail "$JENKINS_SLAVE_JAR not accessible")

SLAVE_ARGS=()

[[ -n "$JAVA_ARGS" ]] &&
SLAVE_ARGS+=("$JAVA_ARGS")

SLAVE_ARGS+=(-jar "$JENKINS_SLAVE_JAR")

[[ -n "$JENKINS_SLAVE_MODE" ]] &&
SLAVE_ARGS+=(-mode "$JENKINS_SLAVE_MODE")

[[ -n "$EXECUTORS" ]] &&
SLAVE_ARGS+=(-executors "$EXECUTORS")

[[ -n "$JENKINS_USERNAME" ]] &&
SLAVE_ARGS+=(-username "$JENKINS_USERNAME")

[[ -n "$JENKINS_PASSWORD" ]] &&
export JENKINS_PASSWORD &&
SLAVE_ARGS+=(-passwordEnvVariable JENKINS_PASSWORD)

[[ -n "$CLIENT_NAME" ]] &&
SLAVE_ARGS+=(-name "$CLIENT_NAME")

[[ -n "$MASTER_URL" ]] &&
SLAVE_ARGS+=(-master "$MASTER_URL")

if [ -n "$LABELS" ]; then
for l in $LABELS; do
SLAVE_ARGS+=(-labels "$l")
done
fi

[[ -n "$FSROOT" ]] &&
SLAVE_ARGS+=(-fsroot "$FSROOT")

[[ "$DISABLE_CLIENTS_UNIQUE_ID" == true ]] &&
SLAVE_ARGS+=(-disableClientsUniqueId)

[[ "$DISABLE_SSL_VERIFICATION" == true ]] &&
SLAVE_ARGS+=(-disableSslVerification)

[[ "$DELETE_EXISTING_CLIENTS" == true ]] &&
SLAVE_ARGS+=(-deleteExistingClients)

[[ -n "$DESCRIPTION" ]] &&
SLAVE_ARGS+=(-description "$DESCRIPTION")

[[ -n "$AUTO_DISCOVERY_ADDRESS" ]] &&
SLAVE_ARGS+=(-autoDiscoveryAddress "$AUTO_DISCOVERY_ADDRESS")

if [ -n "$TOOL_LOCATIONS" ]; then
for t in $TOOL_LOCATIONS; do
SLAVE_ARGS+=(--toolLocation "$t")
done
fi

[[ -n "$OTHER_ARGS" ]] &&
SLAVE_ARGS+=("$OTHER_ARGS")

$JAVA "${SLAVE_ARGS[@]}"