microsoft/Oryx

Scripts in appsvc.yaml are mangled by replacing newlines with semicolons

J-M0 opened this issue · 0 comments

J-M0 commented

Bug Report

  • At what date and time did you most recently experience the problem?

April 29, 2024 11:00 AM EDT

  • Where did you experience the problem? E.g. Azure Web Apps, Azure Functions, Azure Container Registry, or offline use.

Azure Web Apps

  • If your repo is publicly available please share its URL:

N/A

  • What happened?

The build service mangles the pre- and post-build scripts in appsvc.yaml by blindly replacing every newline with a semicolon. This can result in invalid shell syntax and a build failure.

Problem code is here:

this.cliOptions.PreBuildCommand = buildConfigFile.Prebuild.Replace("\r\n", ";").Replace("\n", ";");

and here:

this.cliOptions.PostBuildCommand = buildConfigFile.Postbuild.Replace("\r\n", ";").Replace("\n", ";");

  • What did you expect or want to happen?

My build to pass and my scripts to not be modified

  • How can we reproduce it?

Create an appsvc.yaml with the following content:

version: 1

pre-build: |
  if true; then
      echo Pre-build script ran successfully
  fi
  • Do you have log output? Please include between the backticks:
Deploy Async
Updating branch 'master'.
Updating submodules.
Preparing deployment for commit id 'b85a120746'.
PreDeployment: context.CleanOutputPath False
PreDeployment: context.OutputPath /home/site/wwwroot
Repository path is /home/site/repository
Running oryx build...
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20230508.1, Commit: 7fe2bf39b357dd68572b438a85ca50b5ecfb4592, ReleaseTagName: 20230508.1

Build Operation ID: 93a2122bf380fa0c
Repository Commit : b85a12074694b3cd0ca4a9698e45e0df6a431f4e
OS Type           : bullseye
Image Type        : githubactions

Detecting platforms...
Detected following platforms:
  python: 3.10.13

Found BuildConfigurationFile
Overriding the pre-build commands with the BuildConfigurationFile section
        if true; then;  echo Pre-build script ran successfully;fi;

Using intermediate directory '/tmp/8dc685f7d24a77f'.

Copying files to the intermediate directory...
Done in 0 sec(s).

Source directory     : /tmp/8dc685f7d24a77f
Destination directory: /home/site/wwwroot

Executing pre-build command...
/tmp/BuildScriptGenerator/c9d188f914de4b4bb3c873ac914f9216/build.sh: line 100: syntax error near unexpected token `;'

Generating summary of Oryx build
Parsing the build logs
Found 0 issue(s)

Build Summary :
===============
Errors (0)
Warnings (0)

Deployment Failed. deployer =  deploymentPath =
Deployment failed
Error - Changes committed to remote repository but deployment to website failed.