Unable to see node output - Need help

Presently I’m working on a custom step to assist with necessary Jira actions. You can view it here, if you’d like to help View Repository.

In the step.sh.old you’re able to see what I was originally doing, but when I ran the job the it hung, timed out, and then eventually failed. First I battled the execution path problems, which i’m not sure it worked out… yet that error went away. Once it continued then it just hung as described above. I assume it was because of missing input variables, however I can directly see that because no error gets emitted.

As a test… I replaced my step.sh with a simple; console.log(‘hello’) - In hope to see that message in the bitrise logs… But alas I see nothing.

What am I doing wrong… Got a couple other questions on this topic of custom steps, but will place in separated thread.

How did you run it?

There’s also no need for this: https://github.com/loudbinary/bitrise_report_to_jira/blob/master/step.sh#L67

Instead of

output=$(npm install);
echo "$output";

you could simply

npm install

if you don’t use the output as a variable (which it seems you don’t).

I created a very small build job in Bitrise.

---
format_version: 1.3.4
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
trigger_map:
  - push_branch: "*"
  workflow: primary
- pull_request_target_branch: "*"
 pull_request_source_branch: "*"
   workflow: primary
   - tag: "*"
    workflow: primary
    workflows:
      primary:
        steps:
        - activate-ssh-key@3.1.1: {}
        - nvm@1.0.1:
        inputs:
        - node_version: 6.9.4
        - git::https://github.com/loudbinary/bitrise_report_to_jira.git@master:
        title: Report to Jira
        inputs:
        - jira_url: https://loudbinary.atlassian.net
        - jira_user: loudbinary@gmail.com
        - jira_password: SomeRandomandLessThanUseFul
        - jira_default_project: LWS
        - jira_default_issue_type: Bug
        - jira_port: 443
        - jira_create_missing: true

Did you try to run it locally, with the Bitrise CLI?

No… not via your cli. I did verify my node script runs successfully, if given the parameters.

I will however, run it specifically with the relative path to my local steplib collection. Will let you know in a few.

That said, I had to go through examples to find what I believe is the appropriate method in step.sh to find the path of my imported step. But honestly I’m not sure this is correct. I assume this custom step with git::https is simply pulling into local collection cache?? Bear with me, only a day or so into this custom step stuff.

THIS_SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

Correct, that’s a random directory.

Correct, see e.g. this step, which is written entirely in Ruby: https://github.com/bitrise-io/steps-amazon-s3-deploy/blob/master/step.sh

The step.sh of the step is as simple as:

#!/bin/bash

THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -e

ruby "${THIS_SCRIPT_DIR}/s3deploy.rb"

It just gets the step.sh file’s directory path with THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )", and then it runs the s3deploy.rb which is in the same directory as the step.sh.

You definitely should! :wink:

And it’s actually quite simple, if you follow the Step Template: GitHub - bitrise-steplib/step-template: Step template - DEPRECATED, please use the `step` plugin and its built in template instead (https://github.com/bitrise-core/bitrise-plugins-step/tree/master/create/templates)