0

Here are some basic infos:

  • windows server 2016
  • CI/CD: jenkins running on windows server 2016

I have a msvc program, I start the building by calling a powershell script. I can run it successfully at local machine. But if I attempt to call the build script in pipeline script, sometimes the pipeline goes well, sometimes the pipeline gets error in the build stage.

Here is the error occurred, but the pipeline goes well.

powershell.exe : build sdk include:C:\Program Files\Huawei\DevEco Studio\sdk\default\openharmony\native\sysroot\usr\include
D:\data\workspace\CTP_COMPILE_develop\ctp\ctp_build@tmp\durable-a9a169cf\powershellWrapper.ps1:3 character: 1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (build sdk inclu...oot\usr\include:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

There is another siuation when run the robocopy command, if the robocopy ends, the pipeline terminates occasionally.

These two situations won't occur at the same time, mostly is the second, if the second error occurred, the pipeline failed.

The following is my part pipeline script:

                    String thirdPartySrc = "D:\\deps\\thirdparty"
                    String thirdPartyDest = "thirdparty"

                    echo "Copying ctp_thirdparty from ${thirdPartySrc} to ${thirdPartyDest}"
                    bat """
                        robocopy "${thirdPartySrc}" "${env.WORKSPACE}\\${thirdPartyDest}" /MIR /XC /XO /XN
                    """

                    dir("build") {
                        powershell """
                            .\\build_targets.ps1 -TARGET_OS harmonyos -TARGET_ARCH x86_64 -INTERACTIVE_MODE 0 -BUILD_TYPE Release
                        """
                        powershell """
                            .\\build_targets.ps1 -TARGET_OS win -TARGET_ARCH x86_64 -INTERACTIVE_MODE 0 -BUILD_TYPE Release -CLEAN_ALL 1
                        """
                    }

And this is my main part build script:

    $cmakeArg = $env:OHOS_CMAKE_COMMON_ARG + "-B `"$BUILD_CACHE_FOLDER/$CURRENT_PROJECT`""
    Write-Host "$CURRENT_PROJECT cmakeArg: $cmakeArg"

    # compile
    Start-Process -NoNewWindow -Wait $env:OHOS_CMAKE_BIN -ArgumentList $cmakeArg
    $processReturn = Start-Process -NoNewWindow -PassThru -Wait $env:OHOS_CMAKE_BIN -ArgumentList "--build `"$BUILD_CACHE_FOLDER/$CURRENT_PROJECT`""

    if ($processReturn.ExitCode -ne 0) {
        Write-Error "Build $CURRENT_PROJECT failed"
        cd $ROOT_DIR\${PROJECT_PREFIX}_build
        exit 1
    }

I think the error may be related to the powershell? How to solve this problem?

4
  • You are getting NativeCommandError. See following : stackoverflow.com/questions/2095088/… Commented Aug 12 at 12:13
  • What's the value of $env:OHOS_CMAKE_BIN? Commented Aug 12 at 13:18
  • $env:OHOS_CMAKE_BIN is the path of haromonyos cmake tool bin directory, I have checked the problem that I lose a `\` in the build_config.json, I have updated my problem. Commented Aug 13 at 2:08
  • Did you try to add at end of powershell command "> $null" to suppress the standard error output? Commented Aug 13 at 12:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.