Build Habitat plan is failing while Integrating Habitat with Azure Devops

Hello,

I have installed the Habit extension to Azure Devops to Implement CI_CD of the Java project.

The build stage is failing with below error. I am working on Window 2019 server edition

Install Habitat - successful
Signing Origin Key - successful
Build Habitat plan - FAILING

##[section]Starting: Build Habitat plan

==============================================================================

Task : Build Plan (Habitat)

Description : Build a Habitat plan

Version : 3.0.46

Author : Chef

Help : More information

==============================================================================

Running as root: true

[command]C:\ProgramData\habitat\hab.exe pkg build -s C:\Users\Administrator\Downloads\habitat\JavaApp\ habitat

WARNING: Using a local Studio. To use a Docker studio, use the -D argument.

hab-studio: Destroying Studio at C:\hab\studios\Users–Administrator–Downloads–habitat–JavaApp–

hab-studio: Creating Studio at C:\hab\studios\Users–Administrator–Downloads–habitat–JavaApp–

XXX

XXX Crypto error: No revisions found for vadiraj sig key

XXX

XXX

XXX Crypto error: No revisions found for vadiraj sig key

XXX

» Importing origin key from standard input

An error occured in the build!

XXX

##[error]The process ‘C:\ProgramData\habitat\hab.exe’ failed with exit code 1

##[section]Finishing: Build Habitat plan

Need help

From the output above it doesn’t appear that your key’s are getting pulled in or shared into the build context. It’s possible that your signing keys are not available on the filesystem where the cli expects them when the build call is passed in - in which case you can use the --cache-key-path flag to tell it where on the filesystem the keyfiles live.

Thanks for your reply. I fixed that.
However when i try to integrate the sample nodejs application provided in the habitat website inside Azure Devops. I get the below error in build step.

[ ] - prepare:src: info lifecycle sample-node-app@0.0.0~prepar

[ ] - prepare:src: info lifecycle sample-node-app@0.0.0~prepar

[?25haudited 209 packages in 1.412s

found 4 vulnerabilities (3 low, 1 critical)

run npm audit fix to fix them, or npm audit for details

5l[ ] / prepare:src: timing audit body Completed in 1ms

[?25h sample-node-app: Installing

cp: cannot stat ‘node_modules’: No such file or directory

cp: cannot stat ‘public’: No such file or directory

cp: cannot stat ‘routes’: No such file or directory

cp: cannot stat ‘views’: No such file or directory

cp: cannot stat ‘package.json’: No such file or directory

cp: cannot stat ‘app.js’: No such file or directory

cp: cannot stat ‘index.js’: No such file or directory

sample-node-app: Build time: 0m15s

sample-node-app: Exiting on error

Script done, file is /src/results/logs/sample-node-app.2019-09-18-071915.log

##[error]The process ‘/tmp/hab’ failed with exit code 1

##[section]Finishing: Build Habitat plan

Though in plan.sh the these modules are copied. Below is the plan.sh

pkg_name=sample-node-app
pkg_origin=vadirajbk_1
pkg_version=“1.1.0”
pkg_deps=(core/node)

Habitat provides you with a number of built-in “callbacks” to use

in the course of your build, all of which are explained in the docs

at https://habitat.sh/docs/reference/#reference-callbacks.

Here, we’re implementing the do_build and do_install callbacks

to install dependencies and assemble the application package.

do_build() {

By default, we’re in the directory in which the Studio was entered

(in this case, presumably the project root), so we can run commands

as though we were in that same directory. By the time we reach this

callback, npm will have been installed for us.

npm install
}

do_install() {

The pkg_prefix variable contains the fully-qualified Studio-relative path to

a specific build run (e.g., /hab/pkgs/<YOUR_ORIGIN>/sample-node-app/1.1.0/20180620174915).

In this callback, we copy the files that our application requires at runtime

into that directory, and once this step completes, Habitat will take

over to produce the finished package as a .hart file.

local app_path="$pkg_prefix/app"
mkdir -p $app_path

cp -R
node_modules
public
routes
views
package.json
app.js
index.js
$app_path
}

Any solution for the above problem is highly appreciated

@vadiraj here are a couple of tips to help you debug:

  1. Build the plan locally on your own machine first. If it works then there is a higher chance of success when you integrate it with CI systems.

  2. Make use of attach. It’s like gdb but for hab plans. :slight_smile: I would put the word attach right before you cp files into $app_path. This will allow you to look around in the file system at that point to see if there are any of the files you said you were trying to copy. Caveat! You might have to run your plan locally because you will need to be interactive with your plan.