Running PHP script after clone

It seems like it should be easy to run a script after Bitrise clones your repo but I can’t seem to get it to work with PHP.

My file is located at /poster.php. It takes 2 command line arg. Tag and API KEY. The API_KEY is stored in a secret.

So i’ve tried:

Script-Runner

$BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY

With config set to:
Execute with / runner binary: php

Do anything with script step

#!/usr/bin/php
# fail if any commands fails
set -e
# debug log
set -x

# write your script here
echo "Bitrise... Building..."

php $BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY

Errors:

php: command not found (Do anything with script step)

file_path: path not exist at: /bitrise/src/poster.php (Script-runner)

Not sure how to get this thing working, any help is appriciated

Switching to Xcode instead of Ubunto did the trick!

Hey @ehuda!

Glad to hear you solved the issue! Thanks for leaving it here, I’m sure it will help others stumbling into similar ones :slightly_smiling_face:

@bitce I’m actually getting stuck again. Any chance you could help out?

---
format_version: '5'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
trigger_map:
- pull_request_source_branch: "*"
  workflow: primary
- tag: "*"
  workflow: primary
workflows:
  primary:
    steps:
    - activate-ssh-key@3.1.1:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4.0.11: {}
    - script-runner@0.9.3:
        inputs:
        - runner: php
        - is_debug: 'yes'
        - file_path: "$BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY $WEBSITE"
    - script@1.1.5:
        title: Do anything with Script step
        inputs:
        - is_debug: 'yes'
        - runner_bin: php
        - content: |-
            #!/usr/bin/php
            # fail if any commands fails
            set -e
            # debug log
            set -x

            php $BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY $WEBSITE
        is_always_run: true
    - deploy-to-bitrise-io@1.3.12: {}

I understand that script-runner wont work because i’m trying to add command line argument to the file path but I don’t understand why the script@1.1.5 wont work.

It says it ended successfully but the script doesn’t seem to have run. Are the env variables not getting converted?

How would I properly run this code? Just to recap. I have a php script in my github repo. Im trying to call it using:

php $BITRISE_SOURCE_DIR/poster.php $BITRISE_GIT_TAG $API_KEY $WEBSITE

Hey @ehuda!

Can you send us the URL to the build please so we can see everything that’s going on in there?

If you are facing some kind of process to generate the entire knowledge regarding the process to setup the installation of the PHP can be better if you get the process from the help of the Google Drive Support to generate the entire process for the knowledge.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.