Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.bitrise*
ssh/
6 changes: 3 additions & 3 deletions _tests/test_ok.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
THIS_SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${THIS_SCRIPTDIR}"

export SSH_RSA_PRIVATE_KEY=$(<testkey_ok)
export SSH_KEY_SAVE_PATH="$(PWD)/testsave"
export IS_REMOVE_OTHER_IDENTITIES="true"
export ssh_rsa_private_key=$(<testkey_ok)
export ssh_key_save_path="$(PWD)/testsave"
export is_remove_other_identities="true"

bash ../step.sh
if [ $? -ne 0 ] ; then
Expand Down
6 changes: 3 additions & 3 deletions _tests/test_wrong.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
THIS_SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${THIS_SCRIPTDIR}"

export SSH_RSA_PRIVATE_KEY=$(<testkey_wrong)
export SSH_KEY_SAVE_PATH="$(PWD)/testsave"
export IS_REMOVE_OTHER_IDENTITIES="true"
export ssh_rsa_private_key=$(<testkey_wrong)
export ssh_key_save_path="$(PWD)/testsave"
export is_remove_other_identities="true"

bash ../step.sh
if [ $? -eq 0 ] ; then
Expand Down
17 changes: 17 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
format_version: 0.9.10
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

app:
envs:
# define these in your .bitrise.secrets.yml
- TEST_SSH_RSA_PRIVATE_KEY:

workflows:
test:
steps:
- path::./:
run_if: true
inputs:
- ssh_rsa_private_key: $TEST_SSH_RSA_PRIVATE_KEY
- ssh_key_save_path: "$HOME/.ssh/bitrise_step_activate_ssh_key"
- is_remove_other_identities: "true"
14 changes: 7 additions & 7 deletions step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ function CLEANUP_ON_ERROR_FN {
CONFIG_ssh_key_file_path="$HOME/.ssh/steplib_ssh_step_id_rsa"
CONFIG_is_remove_other_identities="true"

if [ -z "${SSH_RSA_PRIVATE_KEY}" ] ; then
if [ -z "${ssh_rsa_private_key}" ] ; then
write_section_to_formatted_output "# Error"
write_section_start_to_formatted_output '* Required input `$SSH_RSA_PRIVATE_KEY` not provided!'
write_section_start_to_formatted_output '* Required input `$ssh_rsa_private_key` not provided!'
exit 1
fi

if [ ! -z "${SSH_KEY_SAVE_PATH}" ] ; then
CONFIG_ssh_key_file_path="${SSH_KEY_SAVE_PATH}"
if [ ! -z "${ssh_key_save_path}" ] ; then
CONFIG_ssh_key_file_path="${ssh_key_save_path}"
fi

if [ ! -z "${IS_REMOVE_OTHER_IDENTITIES}" ] ; then
if [[ "${IS_REMOVE_OTHER_IDENTITIES}" == "false" ]] ; then
if [ ! -z "${is_remove_other_identities}" ] ; then
if [[ "${is_remove_other_identities}" == "false" ]] ; then
CONFIG_is_remove_other_identities="false"
fi
fi
Expand All @@ -37,7 +37,7 @@ echo_string_to_formatted_output "* Should remove other identities from the ssh-a

dir_path_of_key_file=$(dirname "${CONFIG_ssh_key_file_path}")
print_and_do_command_exit_on_error mkdir -p "${dir_path_of_key_file}"
echo "${SSH_RSA_PRIVATE_KEY}" > "${CONFIG_ssh_key_file_path}"
echo "${ssh_rsa_private_key}" > "${CONFIG_ssh_key_file_path}"
if [ $? -ne 0 ] ; then
write_section_to_formatted_output "# Error"
echo_string_to_formatted_output "* Failed to write the SSH key to the provided path"
Expand Down
53 changes: 33 additions & 20 deletions step.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
name: |
Activate SSH key (RSA private key)
description: |
title: Activate SSH key (RSA private key)
summary: Activate SSH key (RSA private key)
description: |-
Saves the provided **RSA private SSH key** to file
and then loads it into the user's ssh-agent with `ssh-add`.

Expand All @@ -12,25 +11,39 @@ description: |

It will start the ssh-agent if it can't connect to the agent.
website: https://github.com/bitrise-io/steps-activate-ssh-key
source:
git: https://github.com/bitrise-io/steps-activate-ssh-key.git
source_code_url: https://github.com/bitrise-io/steps-activate-ssh-key
support_url: https://github.com/bitrise-io/steps-activate-ssh-key/issues
host_os_tags:
- osx-10.9
project_type_tags:
- ios
type_tags:
- ssh
requires_admin_user: false

is_always_run: false
is_skippable: false
run_if: ".IsCI"
inputs:
- title: |
SSH private key in RSA format
mapped_to: SSH_RSA_PRIVATE_KEY
is_expand: false
- title: |
(Optional) path to save the private key. Default is: $HOME/.ssh/steplib_ssh_step_id_rsa
mapped_to: SSH_KEY_SAVE_PATH
is_expand: true
- title: |
(Optional) Remove other, previously loaded keys and restart ssh-agent?
Options: true and false. Default: true.
mapped_to: IS_REMOVE_OTHER_IDENTITIES
is_expand: false
- ssh_rsa_private_key: "$SSH_RSA_PRIVATE_KEY"
opts:
title: SSH private key in RSA format
is_expand: true
is_dont_change_value: true
- ssh_key_save_path: "$HOME/.ssh/bitrise_step_activate_ssh_key"
opts:
title: |-
(Optional) path to save the private key. Default is: $HOME/.ssh/steplib_ssh_step_id_rsa
is_expand: true
is_dont_change_value: true
- is_remove_other_identities: "true"
opts:
description: |-
(Optional) Remove other, previously loaded keys and restart ssh-agent?

Options:

* "true"
* "false"
is_expand: false
value_options: ["true", "false"]
is_dont_change_value: true