Grunt task

Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015.3

Use this task in a build or release pipeline to run Grunt tasks using the JavaScript Task Runner.

Demands

The build agent must have the following capability:

  • Grunt

YAML snippet

# Grunt
# Run the Grunt JavaScript task runner
- task: Grunt@0
  inputs:
    #gruntFile: 'gruntfile.js' 
    #targets: # Optional
    #arguments: # Optional
    #workingDirectory: # Optional
    #gruntCli: 'node_modules/grunt-cli/bin/grunt' 
    #publishJUnitResults: false # Optional
    #testResultsFiles: '**/TEST-*.xml' # Required when publishJUnitResults == True
    #testRunTitle: # Optional
    #enableCodeCoverage: false # Optional
    #testFramework: 'Mocha' # Optional. Options: mocha, jasmine
    #srcFiles: # Optional
    #testFiles: 'test/*.js' # Required when enableCodeCoverage == True

Arguments

Argument Description
gruntFile
Grunt File Path
(Required) Relative path from the repo root to the Grunt script that you want to run.
Default value: gruntfile.js
targets
Grunt task(s)
(Optional) Space delimited list of tasks to run. If you leave it blank, the default task will run.
arguments
Arguments
Additional arguments passed to Grunt. See Using the CLI.
Tip: --gruntfile is not needed. This argument is handled by the Grunt file path argument shown above.
cwd
Working Directory
(Optional) Current working directory when the script is run. If you leave it blank, the working directory is the folder where the script is located.
Argument aliases: workingDirectory
gruntCli
grunt-cli location
(Required) grunt-cli to run when agent can't find global installed grunt-cli Defaults to the grunt-cli under node_modules folder of the working directory.
Default value: node_modules/grunt-cli/bin/grunt
Argument aliases: workingDirectory
publishJUnitResults
Publish to Azure Pipelines
Select this option to publish JUnit test results produced by the Grunt build to Azure Pipelines
Default value: false
testResultsFiles
Test Results Files
(Required) Test results files path. Wildcards can be used. For example, **/TEST-.xml for all XML files whose name starts with TEST-.
Default value: **/TEST-
.xml
testRunTitle
Test Run Title
(Optional) Provide a name for the test run
enableCodeCoverage
Enable Code Coverage
(Optional) Select this option to enable Code Coverage using Istanbul
Default value: false
testFramework
Test Framework
(Optional) Select your test framework
Default value: Mocha
srcFiles
Source Files
(Optional) Provide the path to your source files which you want to hookRequire ()
testFiles
Test Script Files
(Required) Provide the path to your test script files
Default value: test/*.js

Example

See Sample Gruntfile.

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

Q & A

Do I need an agent?

You need at least one agent to run your build or release.

I'm having problems. How can I troubleshoot them?

See Troubleshoot Build and Release.

I can't select a default agent pool and I can't queue my build or release. How do I fix this?

See Agent pools.

I use TFS on-premises and I don't see some of these features. Why not?

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.