Some commands in github step not executed

I have a github workflow which build native images using graalvm, and in the following step, only the first three commands executed and returned success. ./resources/rcedit-x64.exe and dir not executed. More details can be found on add windows app icon and metadata · liudonghua123/spring-boot-native-image@8c70624 · GitHub.

      - name: 'Build Native Image on windows'
        if: matrix.os == 'windows-latest'
        run: |
          dir target
          call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
          mvn clean package -P native -DskipTests
          ./resources/rcedit-x64.exe target/${APP_NAME}${{matrix.executable_extension}} --set-icon resources/app_icon.ico --set-file-version ${{ steps.environment.outputs.PROJECT_VERSION }} --set-product-version ${{ steps.environment.outputs.PROJECT_VERSION }}  --set-version-string ProductName ${{env.APP_NAME}} --set-version-string LegalCopyright MIT
          dir target
        shell: cmd


If I move these commands on another step, then it worked as expected.

The beginning and ending logs (10_Build Native Image on windows.txt) are belows, click me to expand
2021-11-30T08:28:15.7728097Z ##[group]Run call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
2021-11-30T08:28:15.7729237Z e[36;1mcall "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"e[0m
2021-11-30T08:28:15.7729938Z e[36;1mmvn clean package -P native -DskipTestse[0m
2021-11-30T08:28:15.7731200Z e[36;1mresources\rcedit-x64.exe target/${APP_NAME}.exe --set-icon resources/app_icon.ico --set-file-version 0.0.1 --set-product-version 0.0.1  --set-version-string ProductName spring-boot-native-image --set-version-string LegalCopyright MITe[0m
2021-11-30T08:28:15.7732572Z e[36;1mdir targete[0m
2021-11-30T08:28:15.7764946Z shell: C:\Windows\system32\cmd.EXE /D /E:ON /V:OFF /S /C "CALL "{0}""
2021-11-30T08:28:15.7765382Z env:
2021-11-30T08:28:15.7765975Z   APP_NAME: spring-boot-native-image
2021-11-30T08:28:15.7766682Z   JAVA_HOME: C:\hostedtoolcache\windows\GraalVM\java11-windows-amd64-21.3.0\x64
2021-11-30T08:28:15.7767551Z   GRAALVM_HOME: C:\hostedtoolcache\windows\GraalVM\java11-windows-amd64-21.3.0\x64
2021-11-30T08:28:15.7768250Z ##[endgroup]
2021-11-30T08:28:17.0733752Z **********************************************************************
2021-11-30T08:28:17.0734825Z ** Visual Studio 2019 Developer Command Prompt v16.11.7
2021-11-30T08:28:17.0735353Z ** Copyright (c) 2021 Microsoft Corporation
2021-11-30T08:28:17.0736189Z **********************************************************************
2021-11-30T08:28:19.1163887Z [vcvarsall.bat] Environment initialized for: 'x64'
2021-11-30T08:28:21.9445589Z [INFO] Scanning for projects...
2021-11-30T08:28:22.7215706Z Downloading from spring-milestones: https://repo.spring.io/milestone/org/graalvm/buildtools/native-maven-plugin/0.9.7.1/native-maven-plugin-0.9.7.1.pom
2021-11-30T08:28:23.1629204Z Downloading from central: https://repo.maven.apache.org/maven2/org/graalvm/buildtools/native-maven-plugin/0.9.7.1/native-maven-plugin-0.9.7.1.pom
2021-11-30T08:28:23.2413904Z Progress (1): 2.4 kB
2021-11-30T08:28:23.2415046Z                     
2021-11-30T08:28:23.2416164Z Downloaded from central: https://repo.maven.apache.org/maven2/org/graalvm/buildtools/native-maven-plugin/0.9.7.1/native-maven-plugin-0.9.7.1.pom (2.4 kB at 27 kB/s)
2021-11-30T08:28:23.2593919Z Downloading from spring-milestones: https://repo.spring.io/milestone/org/graalvm/buildtools/junit-platform-native/0.9.7.1/junit-platform-native-0.9.7.1.pom
2021-11-30T08:28:23.2894039Z Downloading from central: https://repo.maven.apache.org/maven2/org/graalvm/buildtools/junit-platform-native/0.9.7.1/junit-platform-native-0.9.7.1.pom
...
2021-11-30T08:29:26.3224493Z [spring-boot-native-image:1628]    classlist:   6,541.04 ms,  0.96 GB
2021-11-30T08:29:45.8014240Z [spring-boot-native-image:1628]        (cap):  17,908.72 ms,  0.96 GB
2021-11-30T08:29:50.9422354Z [spring-boot-native-image:1628]        setup:  21,248.64 ms,  0.96 GB
2021-11-30T08:29:50.9423952Z The bundle named: org.apache.tomcat.util.threads.res.LocalStrings, has not been found. If the bundle is part of a module, verify the bundle name is a fully qualified class name. Otherwise verify the bundle path is accessible in the classpath.
2021-11-30T08:31:45.3513120Z [spring-boot-native-image:1628]     (clinit):   1,504.68 ms,  3.38 GB
2021-11-30T08:31:45.6055892Z [spring-boot-native-image:1628]   (typeflow):  35,559.64 ms,  3.38 GB
2021-11-30T08:31:45.6057393Z [spring-boot-native-image:1628]    (objects):  55,491.29 ms,  3.38 GB
2021-11-30T08:31:45.6058165Z [spring-boot-native-image:1628]   (features):  21,328.80 ms,  3.38 GB
2021-11-30T08:31:45.6058982Z [spring-boot-native-image:1628]     analysis: 117,692.43 ms,  3.38 GB
2021-11-30T08:31:54.6862048Z [spring-boot-native-image:1628]     universe:   9,079.18 ms,  3.35 GB
2021-11-30T08:32:08.6084462Z [spring-boot-native-image:1628]      (parse):  13,853.11 ms,  3.38 GB
2021-11-30T08:32:19.2136594Z [spring-boot-native-image:1628]     (inline):  10,063.00 ms,  3.38 GB
2021-11-30T08:33:26.4560231Z [spring-boot-native-image:1628]    (compile):  67,228.08 ms,  3.40 GB
2021-11-30T08:33:30.2795438Z [spring-boot-native-image:1628]      compile:  95,445.61 ms,  3.40 GB
2021-11-30T08:33:36.5082914Z [spring-boot-native-image:1628]        image:   6,320.81 ms,  3.42 GB
2021-11-30T08:33:38.8736965Z [spring-boot-native-image:1628]        write:   2,363.71 ms,  3.42 GB
2021-11-30T08:33:38.8843348Z [spring-boot-native-image:1628]      [total]: 259,153.82 ms,  3.42 GB
2021-11-30T08:33:38.8846042Z # Printing build artifacts to: D:\a\spring-boot-native-image\spring-boot-native-image\target\spring-boot-native-image.build_artifacts.txt
2021-11-30T08:33:39.7931649Z [INFO] ------------------------------------------------------------------------
2021-11-30T08:33:39.7935093Z [INFO] BUILD SUCCESS
2021-11-30T08:33:39.7935991Z [INFO] ------------------------------------------------------------------------
2021-11-30T08:33:39.8124681Z [INFO] Total time:  05:17 min
2021-11-30T08:33:39.8149290Z [INFO] Finished at: 2021-11-30T08:33:39Z
2021-11-30T08:33:39.8150110Z [INFO] ------------------------------------------------------------------------
2 Likes

I think the issue is with the ${APP_NAME} at the beginning of the rcedit command. Did you mean to type ${{env.APP_NAME}}? I see that you have that near the end of that same line.

2 Likes

@Katsute, Thanks, But I have defined the APP_NAME in the top env of the workflow yaml. According to the Environment variables, it is safe to use ${APP_NAME} here, and if the ${APP_NAME} could not replaced when execution, some errors should be appeared.

Anyway I will try to modify and test.

To use the value of an environment variable in a workflow file, you should use the env context. If you want to use the value of an environment variable inside a runner, you can use the runner operating system’s normal method for reading environment variables.

If you use the workflow file’s run key to read environment variables from within the runner operating system (as shown in the example above), the variable is substituted in the runner operating system after the job is sent to the runner. For other parts of a workflow file, you must use the env context to read environment variables; this is because workflow keys (such as if ) require the variable to be substituted during workflow processing before it is sent to the runner.

2 Likes

I tried, it’s the same issue, the highlighted commands not executed. More details on testing · liudonghua123/spring-boot-native-image@c6adfcf · GitHub.

2 Likes

I think maybe the execution resources of some commands are too high and the rest commands are get ignored then.

2 Likes

I tried to add more debuging info in this step (testing · liudonghua123/spring-boot-native-image@5efbd69 · GitHub).

      - name: 'Build Native Image on windows'
        if: matrix.os == 'windows-latest'
        run: |
          echo "init vs2019 x64 environment"
          call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
          echo "build native image"
          mvn clean package -P native -DskipTests
          echo "edit binary resources"
          .\resources\rcedit-x64.exe target/${{env.APP_NAME}}${{matrix.executable_extension}} --set-icon resources/app_icon.ico --set-file-version ${{ steps.environment.outputs.PROJECT_VERSION }} --set-product-version ${{ steps.environment.outputs.PROJECT_VERSION }}  --set-version-string ProductName ${{env.APP_NAME}} --set-version-string LegalCopyright MIT
          echo "check target outputs"
          dir target
        shell: cmd

However the following commands after mvn build is not executed.

          echo "edit binary resources"
          .\resources\rcedit-x64.exe target/${{env.APP_NAME}}${{matrix.executable_extension}} --set-icon resources/app_icon.ico --set-file-version ${{ steps.environment.outputs.PROJECT_VERSION }} --set-product-version ${{ steps.environment.outputs.PROJECT_VERSION }}  --set-version-string ProductName ${{env.APP_NAME}} --set-version-string LegalCopyright MIT
          echo "check target outputs"
          dir target

2 Likes

I think the issue might be with .\resources\rcedit-x64.exe, try changing it to ".\resources\rcedit-x64.exe" with quotes. Starting a command with . is valid for bash but command prompt doesn’t seem to like it.

2 Likes

I tried too, but the same result.

2 Likes

My guess is running .\resources\rcedit-x64.exe is exiting the cmd process for some reason. Try adding a running it with start .\resources\rcedit-x64.exe.

2 Likes

I suspect that maven is suppressing the output windows - How to execute more than one maven command in bat file? - Stack Overflow

3 Likes

I tried to add call before mvn, then it worked as expected. Thanks. @Katsute @chrispat

1 Like