Act: Maven Step Fails

Created on 16 Mar 2020  ·  13Comments  ·  Source: nektos/act

Expected behavior:

  • Maven commands (mvn) execute when using act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04-full

Actual behavior:

  • Maven builds fail due to Maven not being installed.
    ```
    | /github/workflow/3: line 2: mvn: command not found
    [Build, Test, and Upload/Java Application Container] ❌ Failure - Compile and Test Using Maven
    ````

The environments image appears to be either out-of-date, or does not install the same tools/dependencies as the GitHub virtual-environments. This means that currently, Java builds that can be executed directly from GitHub Actions cannot be ran locally.

arerunner kinbug

Most helpful comment

@aaron-goulet-bfg can you share a sample workflow file?

All 13 comments

@aaron-goulet-bfg can you share a sample workflow file?

@aaron-goulet-bfg can you share a sample workflow file?

Anything I can do to help! Here's the relevant portion of the actual workflow that resulted in the above:

name: 'Build, Test, and Upload'

on: [pull_request]

jobs:
  build:
    name: 'Java Application Container'

    runs-on: ubuntu-18.04

    steps:
      - name: 'Checkout Repository'
        uses: actions/checkout@v2
        with:
          token: '${{ secrets.GITHUB_TOKEN }}'

      - name: 'Process Workflow Parameters'
        # Used for naming images.  Currently GitHub Action contexts do not
        # provide the short SHA/digest as a field.
        id: params
        run: |
          echo ::set-output name=app_name::$(echo "${{ github.repository }}" | sed -e 's,.*/\(.*\),\1,');
          echo ::set-output name=sha_digest::$(git rev-parse --short HEAD);
      - name: 'Java Environment Setup'
        uses: actions/setup-java
        with:
          java-version: 11

      - name: 'Compile and Test Using Maven'
        run: 'mvn -B --no-transfer-progress install'
        env:
          GITHUB_REPOSITORY: '${{ github.repository }}'
          APP_NAME: '${{ steps.params.outputs.app_name }}'
          SHA: '${{ steps.params.outputs.sha_digest }}'
# ... SNIP ...

And here's the CLI command used to run it:

 act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04-full -s "GITHUB_TOKEN=<VALID GITHUB TOKEN HERE>"

Here's the script that the Packer template uses to install Maven normally: [[link](https://github.com/actions/virtual-environments/blob/37dee70e0eca4dba94ab23f240057e67cf942eb2/images/linux/scripts/installers/java-tools.sh#L35-L40)]

Issue is stale and will be closed in 7 days unless there is new activity

I got the same error, how can i fix this ?

name: Java CI with Maven
on:
push:
branches: [ '*' ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn --settings .settings.xml -B package

act -v

...
[Java CI with Maven/build] ⭐ Run Build with Maven
DEBU[0093] Wrote command '/usr/bin/mvn --settings .settings.xml -B package' to 'workflow/2'
DEBU[0093] Writing entry to tarball workflow/2 len:104
[Java CI with Maven/build] Extracting content to '/github/'
[Java CI with Maven/build] Exec command '[bash --noprofile --norc -eo pipefail /github/workflow/2]'
| /github/workflow/2: line 2: /usr/bin/mvn: No such file or directory
[Java CI with Maven/build] ❌ Failure - Build with Maven
DEBU[0094] exit with FAILURE: 127
Error: exit with FAILURE: 127

Issue is stale and will be closed in 7 days unless there is new activity

Issue is stale and will be closed in 7 days unless there is new activity

@vroyer @aaron-goulet-bfg
Temporary workaround until fix is released.

    - name: Download Maven
      run: |
        curl -sL https://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip -o maven.zip
        apt-get update
        apt-get -y install unzip
        unzip -d /usr/share maven.zip
        rm maven.zip
        ln -s /usr/share/apache-maven-3.6.3/bin/mvn /usr/bin/mvn
        echo "M2_HOME=/usr/share/apache-maven-3.6.3" | tee -a /etc/environment

when can we expect a fix for this?

Another decent workaround @jeff-miller-cfa ; use the full docker image

act -j build -P ubuntu-latest=nektos/act-environments-ubuntu:18.04

same problem here

same problem here

@vroyer @aaron-goulet-bfg
Temporary workaround until fix is released.

    - name: Download Maven
      run: |
        curl -sL https://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip -o maven.zip
        apt-get update
        apt-get -y install unzip
        unzip -d /usr/share maven.zip
        rm maven.zip
        ln -s /usr/share/apache-maven-3.6.3/bin/mvn /usr/bin/mvn
        echo "M2_HOME=/usr/share/apache-maven-3.6.3" | tee -a /etc/environment

Thank you, this helps!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomasaschan picture tomasaschan  ·  4Comments

jclem picture jclem  ·  6Comments

HoughIO picture HoughIO  ·  4Comments

Applelo picture Applelo  ·  5Comments

ovitente picture ovitente  ·  6Comments