Skip to content
Ryan Valizan edited this page Sep 15, 2020 · 5 revisions

Commonly Asked Questions

Here you will find commonly asked questions as well as insightful information to the project.

Table of Contents


How to use script

Update remote server with new release

Shell Script:

bash wp-git-sync.sh \
  -fo $https_repo_with_user_and_token

Azure DevOps Pipeline:

Place the script in your root project directory, then add the task shown below.

YAML Example:
note: This example uses Azure Key store variables

pool:
  name: NameOfAgentPool

steps:
- task: SSH@0
  displayName: pushChanges
  inputs:
    sshEndpoint: 'DEVOPS_SSH_ENDPOINT'
    runOptions: script
    scriptPath: 'wp-git-sync.sh'
    args: '-fo "https://$(DevOpsTokenUser):$(DevOpsToken)@ORGANIZATION-NAME.visualstudio.com/$(System.TeamProject)/_git/$(Build.Repository.Name)"

Classic Editor Example:

PipelineScreen

Console Log:

WordPress-SSH-Git-CI


Fetch changes on remote server

Shell Script:

bash wp-git-sync.sh \
  -fo $https_repo_with_user_and_token
  -fe

Azure DevOps Pipeline:

Place the script in your root project directory, then add the task shown below.

YAML Example:
note: This example uses Azure Key store variables

pool:
  name: NameOfAgentPool

steps:
- task: SSH@0
  displayName: fetchChanges
  inputs:
    sshEndpoint: 'DEVOPS_SSH_ENDPOINT'
    runOptions: script
    scriptPath: 'wp-git-sync.sh'
    args: '-fo "https://$(DevOpsTokenUser):$(DevOpsToken)@ORGANIZATION-NAME.visualstudio.com/$(System.TeamProject)/_git/$(Build.Repository.Name)" \
            -fe'

Classic Editor Example:

PipelineScreen

Console Log:

WordPress-SSH-Git-CI


Argument Options

  # Server side live branch to use
  -b|--branch) #optional -- default is live

  # Branch to commit and push changes to
  -d|--devbranch) #optional 0-- default is dev

  # Only fetching for changes on the server
  -fe|--fetch) #optional

  # Full url and authentication for script to use for server side git commands
  -fo|--fullorigin) #semi-optional -- if empty gitrepo, token, and tokenuser are required

  # Repo URL string I.E. gibhub.com/user/repo-name | dev.azure.com/org/project/_git/repo
  -g|--gitrepo) #semi-optional -- if empty fullorigin string is required

  # Custom commit message to use if changes are detected
  -m|--message) #optional -- default is Server Side Commit

  # What should the script do when changes are detected.
  # Commit or Stop
  -o|--onchange) #optional -- default is commit

  # Where is the project found on the remote web server
  -pd|--projectdir) #optional -- wordpress is default

  # Branch where releases will be coming in from Azure DevOps
  -sb|--stagebranch) #optional -- default is stage

  # Throw an error if changes are detected but don't commit & still update the web server
  -se|--softerror) #optional -- default is false

  # Auth token to use for remote server talking to Azure DevOps
  -to|--token) #semi-optional -- if empty fullorigin string is required

  # Only stash tracked files before updating
  -tr|--tracked) #optional -- default is false & true is not tested!

  # Auth user to use for remote server talking to Azure DevOps
  -u|--tokenuser) #semi-optional -- if empty fullorigin string is required

Exit Error Message Numbers

Currently, not all of these numbers are being used; however, they were at one time or are planned to be used in the future.

# ERROR CODES EXPLAINED
## ERROR 2 = Missing required parameter option.
## ERROR 3 = Stopping for human intervention.
## ERROR 4 = Repository needs synced before it can pull changes.
Clone this wiki locally