admin管理员组

文章数量:1122832

I'm setting up a Bitbucket pipeline to deploy a PHP application. The goal is to connect through SSH to a remote server, do a git pull and run a deploy_dev.sh script.

Everything is running fine, except the deploy_dev.sh script. When the pipeline executes that one, I get bash: line 1: php: command not found

PHP is installed on the remote server, and running the same command directly on the server (with the same SSH user) executes it perfectly.

I assume I don't need PHP in the docker container, when I connect via SSH on a remote server. Am I missing something else? Is there a difference between interactive & non-interactive SSH sessions? If so, how can I add PHP (and other aliasses) to the PATH?

If I echo the $PATH variable via SSH myself, I get more content & directories compared to the contents through SSH via the Bitbucket pipelines. ps: remote server is Ubuntu with Plesk on it.

Hereby my bitbucket-pipelines.yml content:

image: atlassian/default-image:latest

definitions:
  steps:
    - step: &backend-syntax-check
        name: Searching for PHP syntax errors
        image: php:8.0-cli
        script:
          - find . -regextype posix-egrep -regex '^.*\.(module|install|inc|php|theme)$' | while read filename ; do php -l $filename || exit 1 ; done
    - step: &frontend-syntax-check
        name: Searching for JS and CSS syntax errors
        script:
          - npm install -g acorn
          - find web -name *.js | grep -P '^web\/(modules|themes)\/custom\/(?!(glazed|sooperthemes))' | while read filename ; do acorn --allow-hash-bang --ecma9 --silent $filename || exit 1 ; done
          - npm install -g csslint
          - find web -name *.css | grep -P '^web\/(modules|themes)\/custom\/(?!(glazed|sooperthemes))' | while read filename ; do if [ "${filename##*/}" != "bootstrap.css" ]; then csslint --quiet --format=compact --warnings=display-property-grouping,known-properties,font-faces,import,zero-utils,overqualified-elements,floats,font-sizes,ids,important,outline-none --ignore=box-model,duplicate-properties,empty-rules,adjoining-classes,box-sizing,compatible-vendor-prefixes,gradients,text-indent,vendor-prefix,fallback-colors,star-property-hack,underscore-property-hack,bulletproof-font-face,regex-selectors,universal-selector,unqualified-attributes,shorthand,duplicate-background-images,order-alphabetical,qualified-headings,unique-headings $filename || exit 1 ; fi ; done

pipelines:
  default:
    #- step: *backend-syntax-check
    #- step: *frontend-syntax-check
  branches:
    dev:
      - step:
          name: Deploy to DEV
          deployment: dev
          script:
            - echo "Git pull"
            - pipe: atlassian/ssh-run:0.8.1
              variables:
                SSH_USER: $SSH_USERNAME
                SERVER: $SSH_HOSTNAME
                MODE: "command"
                #DEBUG: "true"
                COMMAND: 'php -v && cd drupal && git pull && cd scripts/deploy && ./deploy_dev.sh'
            - echo "Deploy step finished"

Thanks for any help!

I tried different commands, included a PHP docker image, validated if PHP is running on the remote server. Nothing worked, unless PHP commands can be executed properly when logging in through SSH myself (excluding Bitbucket).

本文标签: Running PHP commands on remote server via SSH with Bitbucket pipelinesStack Overflow