Open ryvo opened 7 years ago
As I always ask, is your npm install && npm run build
working without this plugin?
As I can see here, your dependency https://github.com/angularjs-oauth/oauth-ng needs bower, but your pom.xml doesn't include it.
You're right. I was able to 'npm install && npm run build' locally because I have bower installed globally. I added bower into my dev dependencies and I'm getting another error now:
[INFO] > bower install
[INFO]
[ERROR] bower ESUDO Cannot be run with sudo
[ERROR]
[ERROR] Additional error details:
[ERROR] Since bower is a user command, there is no need to execute it with superuser permissions.
[ERROR] If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.
[ERROR]
[ERROR] http://www.joyent.com/blog/installing-node-and-npm
[ERROR] https://gist.github.com/isaacs/579814
[ERROR]
[ERROR] You can however run a command with sudo using --allow-root option
I don't know how to run 'bower install' with --allow-root option as it is called by one of dependencies. I tried to add --allow-root option on 'npm install' in the pom but I'm still getting the error. It's not possible to run the build as non-root user at BitBucket.
add --allow-root
to your run script in your package.json. This is where bower install
is called, isn't it?
And you can run npm install
with --unsafe-perm
to avoid problems with sudo/root. See https://docs.npmjs.com/misc/scripts#user
I added --unsafe-perm option to 'npm install' in my pom.xml but I'm still getting the same error: 'bower ESUDO Cannot be run with sudo'. Script from my package.json should be called in next step but it's not called at all as the preceding step 'npm install --unsafe-perm' fails. So I need to resolve 'npm install --unsafe-perm' issue first. I tried adding --allow-root to 'npm install --unsafe-perm' did not help. I did not add it to package.json script as it doesn't get called.
This is my current pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cz.proclaim.pet</groupId>
<artifactId>proclaim-web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v6.10.0</nodeVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install --unsafe-perm</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<publisher>
<contextUrl>${url}</contextUrl>
<username>${username}</username>
<password>${password}</password>
<repoKey>proclaim-releases-maven</repoKey>
<snapshotRepoKey>proclaim-snapshots-maven</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
</project>
And package.json:
{
"name": "proclaim-web",
"version": "0.0.1",
"description": "Frontend for ProClaim",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --content-base app",
"build": "NODE_ENV=production node node_modules/.bin/webpack"
},
"dependencies": {
"angular": "^1.6.3",
"angular-animate": "^1.6.3",
"angular-aria": "^1.6.3",
"angular-bootstrap": "^0.12.2",
"angular-sanitize": "^1.6.3",
"angular-smart-table": "^2.1.8",
"angular-ui-bootstrap": "^2.5.0",
"angular-ui-router": "^0.4.2",
"bootstrap": "^3.3.7",
"bootstrap-select": "^1.12.2",
"jquery": "^3.2.1",
"oauth-ng": "^0.4.10",
"ui-select": "^0.19.6"
},
"devDependencies": {
"bootstrap-sass": "^3.3.7",
"bootstrap-webpack": "0.0.6",
"bower": "^1.8.0",
"css-loader": "^0.27.3",
"exports-loader": "^0.6.4",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.1",
"html-loader": "^0.4.5",
"html-webpack-plugin": "^2.28.0",
"imports-loader": "^0.7.1",
"less": "^2.7.2",
"less-loader": "^4.0.2",
"ng-annotate-loader": "^0.2.0",
"node-sass": "^4.5.1",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.3",
"style-loader": "^0.14.1",
"url-loader": "^0.5.8",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.2"
}
}
Full log: full_log_2.txt
@mriehema Thank you for your help! I found out that this issue has nothing to do with frontend-maven-plugin but I'll post the solution here for the others.
This is bitbucket.com's pipeline configuration file bitbucket-pipelines.yml:
image: maven:3.3.3
pipelines:
branches:
develop:
- step:
script:
- echo "Running on commit to the 'develop' branch."
- chmod 777 deploy-to-artifactory.bash
- ./deploy-to-artifactory.bash
File deploy-to-artifactory.bash which is called from the file above:
#!/bin/bash -ex
if [ -z "$buildNumber" ]; then
buildNumber=`date +%s`
fi
echo '{ "allow_root": true }' > /root/.bowerrc
mvn install -DskipTests=true
mvn test
mvn -Durl=$ARTIFACTORY_CONTEXT_URL -Dusername=$ARTIFACTORY_USERNAME -Dpassword=$ARTIFACTORY_PASSWORD deploy
Notice line 'echo '{ "allow_root": true }' > /root/.bowerrc'. This will globally configure bower to allow to run as root.
Links: https://bower.io/docs/config/ http://stackoverflow.com/questions/25672924/run-bower-from-root-user-its-possible-how
@ryvo it's useful for me. thanks.
I'm getting following error in the log:
This is my POM.XML:
I'm building my project at bitbucket.com's pipeline. As I understood each build is run in a clean Docker container with root privileges:
It seems there's currently no way to run it as non-root user. The POM.XML is the only POM in the project, there's no parent POM. The project itself doesn't use Bower at all but one of it's dependencies does. Attached is full_log.txt. Thank you!