I have a azure pipeline that runs in the cloud and in there, I basically want to run a Blackduck scan. To make it easy, the blackduck task runs a maven command to build the dependency tree. In order to do so, it scans all the dependencies in my pom.xml.
I currently have 2 feeds in Azure DevOps. 1 feed that store external libraries and 1 to store internal libraries developed in house. All the dependencies that are external, the maven command is able to retrieve but not the internal one. I keep getting a 401 Unauthorized error.
I have updated my pom.xml to include the credentials to connect to azure artifact as shown here. I have also updated the settings.xml file to include the connection as well. Before the maven command is run, I have added the Maven authenticate task
Yml pipeline:
- task: PowerShell#2
displayName: "Modify Settings.xml"
inputs:
targetType: 'inline'
script: |
$xmlPom = [xml]"<server>
<id>Pack-All</id>
<username>Bob</username>
<password>$(ado.pat)</password>
</server>"
$file = "settings.xml"
$origin = "$(M2_HOME)\conf"
$xdoc = new-object System.Xml.XmlDocument
$fileXml = resolve-path(“$origin\$file”)
$xdoc.load($fileXml)
$xdoc.settings.servers.AppendChild($xdoc.ImportNode($xmlPom.server, $true))
$xdoc = [xml] $xdoc.OuterXml.Replace(" xmlns=`"`"", "")
$xdoc.Save(“$origin\$file”)
- task: MavenAuthenticate#0
displayName: 'Maven Authenticate'
inputs:
artifactsFeeds: 'Pack-All'
- task: SynopsysDetectTask#2
displayName: "Run Black Duck analysis"
condition: and(succeeded(), eq('${{ parameters.blackduck }}', 'true'))
continueOnError: true
inputs:
Products: 'BD'
BlackDuckService: 'Black Duck'
DetectVersion: 'latest'
DetectArguments: '--detect.project.name=$(Build.Repository.Name)Test --detect.binary.scan.file.path=$(Build.SourcesDirectory)\app.war --detect.maven.build.command=-DmavenFeedAuthenticate=true'
Maven command that the Blackduck task executes:
C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin\mvn.cmd -DmavenFeedAuthenticate=true dependency:tree -T1
Error Log:
[ERROR] Failed to execute goal on project dimload-ms-app-agg: Could not resolve dependencies for project ca.test-ms-app-agg:war:0.0.1-SNAPSHOT: Failed to collect dependencies at ca.cn.boot:helpers:jar:0.4.28950: Failed to read artifact descriptor for ca.test.boot:helpers:jar:0.4.28950: Could not transfer artifact ca.test.boot:helpers:pom:0.4.28950 from/to Test-All (https://pkgs.dev.azure.com/Test-Int/_packaging/Pack-All/maven/v1): Authentication failed for https://pkgs.dev.azure.com/Test-Int/_packaging/Pack-All/maven/v1/ca/test/boot/helpers/0.4.28950/helpers-0.4.28950.pom 401 Unauthorized -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
From your Yaml Sample, you have added the MavenAuthenticate task. This task will automatically generate a settings.xml for the target feed.
This file exists in the path xxx\.m2\settings.xml
So you don't need to add this file(settings.xml)manually. This can also help you simplify your code.
Authentication failed for https://pkgs.dev.azure.com/.... 401 Unauthorized
The possible cause of this issue is that the build service account does not have sufficient permissions for the feed.
You could try the following steps:
Navigate to Artifacts ->Target Feed ->Feed Settings -> Permission.
Set the Project Build Service(ProjectName Build Service(OrganizationName)) As Contributor role within the target feed.
Or you could enable the option Allow Project-Scoped Builds.
On the other hand, from the feed URL, it seems to be an Organization-Scope feed.
You could check the Limit job authorization scope to current project for non-release pipelines option is Enabled in Project Settings -> Pipelines.
You could try to disable the option.
Note: To disable this option, you need to disable the option in Organization Settings-> Settings first. Then you could disable the option in Project level.
Related
I run the command below with GitLab CI / CD:
mvn -s /etc/gitlab-runner/maven/settings-maven.xml --batch-mode test sonar:sonar
-Dsonar.java.source=1.8
-Dsonar.host.url=${SONARHOST}
-Dsonar.projectKey=${SONARKEY}
-Dsonar.projectName=${SONARNAME}
-Dsonar.projectVersion=${SONARVERSION}
-Dsonar.sources=myproject_core/src/main/java,myproject_service/src/main/java,myproject_persistance/src/main/java
-Dsonar.language=java
-Dsonar.java.binaries=myproject_core/target/classes,myproject_service/target/classes,myproject_persistance/target/classes
-Dsonar.java.libraries=**/*.jar
-Dsonar.java.coveragePlugin=jacoco
-Dsonar.surefire.reportPaths=myproject_core/target/surefire-reports,myproject_service/target/surefire-reports,myproject_persistance/target/surefire-reports
-Dsonar.junit.reportPaths=myproject_core/target/surefire-reports,myproject_persistance/target/surefire-reports,myproject_service/target/surefire-reports
-Dsonar.verbose=true
-Dsonar.binaries=myproject_core/target/classes,myproject_service/target/classes,myproject_persistance/target/classes
-Dsonar.jacoco.reportPaths=myproject_core/target/jacoco.exec,myproject_service/target/jacoco.exec,myproject_persistance/target/jacoco.exec
-Dsonar.exclusions=**/*Test*/**
-Dsonar.tests=myproject_core/src/test,myproject_service/src/test,myproject_persistance/src/test
So, I want to analyse 3 project core, service and persistance (I have 7 modules in my project)
myproject-parent
myproject-core
myproject-persistance
myproject-service
myproject- ...
But, I have this error :
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project myproject-parent: The directory '/builds/git-myproject/myproject-parent/**myproject_persistance/myproject_core**/src/main/java' does not exist for Maven module fr.xxx.xxx.myproject:myproject_persistance:jar:1.1. Please check the property sonar.sources -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project myproject-parent: The directory '/builds/git-myproject/myproject-parent/myproject_persistance/myproject_core/src/main/java' does not exist for Maven module fr.xxx.xxx.myproject:myproject_persistance:jar:1.1. Please check the property sonar.sources
On this sonarqube error, i can see that in the path, module persistance is include on module core, but this is not the case
I'm looking for why but I can't find. Have you ever had this problem ?
There is a parameter projectVersionPolicyId in many mojos of Maven Release Plugin, e.g. http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#projectVersionPolicyId. However, it seems that they provided no examples of how I can use it.
When I try:
$ mvn --batch-mode release:prepare -DprojectVersionPolicyId=foo
It shows an error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M1:prepare (default-cli) on project maven-release-test: Policy 'foo' is unknown, available: [default] -> [Help 1]
It looks like that there only 1 available policy (which is default). Is there any way to add more possible policies?
You can use SemVerVersionPolicy as well
We built an app with 0.18.0 quarkus version and we have following application.properties:
quarkus.datasource.url=${POSTGRES_DATABASE_URL}
quarkus.datasource.driver=org.postgresql.Driver
quarkus.hibernate-orm.database.generation=update
quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL10Dialect
quarkus.http.port=${PORT:8080}
%dev.quarkus.datasource.url=jdbc:h2:mem:db
%dev.quarkus.datasource.driver=org.h2.Driver
%dev.quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
When I tried upgrading to 0.20.0 (or any version higher, including 1.0.0.Final) I get following error when building with maven:
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:0.20.0:build (default) on project thats-my-spot: Failed to build a runnable JAR: Failed to build a runner jar: Failed to augment application classes: For input string: "${PORT:8080}" -> [Help 1]
Why?
${PORT:8080} just means that it should take either the PORT environment variable if available or use 8080 if not.
I looked at potential issues, changes in semantics but found only one bug that might touch defaults in properties: https://github.com/quarkusio/quarkus/issues/3030 But the description and solution is different, so I don't think that it broke my app.
Can you try with 1.2.1.Final? We had some issues with handling defaults of environment properties at some point but it has been solved for quite a while.
If you can reproduce it with the latest, please open an issue in our tracker with a reproducer and we will have a look.
Can someone please help me with this error?
Jenkins version is 1.624
Plugin version is 1.1.1
failed to expand tokens for [Artifact filename:ear::version]
java.lang.NullPointerException
at org.jvnet.hudson.plugins.repositoryconnector.aether.Aether.convertHudsonNonProxyToJavaNonProxy(Aether.java:151)
at org.jvnet.hudson.plugins.repositoryconnector.aether.Aether.addProxySelectorIfNecessary(Aether.java:139)
at org.jvnet.hudson.plugins.repositoryconnector.aether.Aether.newSession(Aether.java:183)
at org.jvnet.hudson.plugins.repositoryconnector.aether.Aether.resolve(Aether.java:189)
at org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver.download(ArtifactResolver.java:129)
at org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver.perform(ArtifactResolver.java:101)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:381)
Build step 'Artifact Resolver' marked build as failure
Finished: FAILURE
Issue has been resolved....
There was a proxy nexus server setup in Jenkins
Jenkins - manage jenkins - manage plugins- advanced tab
removed the proxy server settings and defined the artifact resolver build step in the jenkins job ...worked fine
Fail on error check the box
Enable repository logging -donot check box
Target directory- leave this empty
Release update policy-always
Snapshot update policy-always
Group Id-ear file group id
Artifact Id-ear fil aritfact id
Version- can be parameterized or use "LATEST"
Extension-ear
Target file name-full ear file name
worked fine plugin 1.1.1 has no issues.
I was doing a build yesterday for the second time of an open source project (Saiku) – I have made no changes to the POM.XML or any of the libraries/jars. The build succeeded a few days ago but now fails. The following pastebin shows the output. The errors are of two types – failure to delete /clean project, and cannot find artifact. Does anyone have any troubleshooting tips?
http://pastebin.com/g2bpAtMS
error type 1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project saiku-core: Failed to clean project: Failed to delete /usr/local/.m2/repository/saiku/saiku-core/target/javadoc-bundle-options/javadoc-options-javadoc-resources.xml
error Type 2
- [ERROR] The build could not read 1 project -> [Help 1]
- [ERROR] The project org.saiku:saiku-webapp:2.2-SNAPSHOT (/usr/local/.m2/repository/saiku/saiku-webapp/pom.xml) has 1 error
- [ERROR] Non-resolvable parent POM: Could not find artifact org.saiku:saiku-core:pom:2.2-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 3, column 10 -> [Help 2]
Are you building within your local repo? That would be bad.
I get similar errors because, I think, my virus checker locks a file underneath the target/ directory and clean cannot delete the directory. I delete the directory manually and resume the build.
Failed to delete /usr/local/.m2/repository/saiku/saiku-core/target/javadoc-bundle-options/javadoc-options-javadoc-resources.xml
You have locked this file. Close every program which could have opened it.
Failed to delete /usr/local/.m2/repository/saiku/saiku-ui/target/classes/routers/QueryRouter.js
Idem for this file.
/usr/local/.m2/repository/saiku/saiku-server/target/saiku-server-foodmart-2.2-SNAPSHOT.tar.gz
Idem for this file.
Could not find artifact org.saiku:saiku-core:pom:2.2-SNAPSHOT and 'parent.relativePath' points at wrong local POM
It seems you have changed something : Maven does not find the parent pom referenced by relativePath attribute.
Check these errors, you always many errors.
I've fixed that by setting relativePath in pom.xml of saiku-webapp:
<parent>
<artifactId>saiku-core</artifactId>
<groupId>org.saiku</groupId>
<version>2.6-SNAPSHOT</version>
<relativePath>../saiku-core/pom.xml</relativePath>
</parent>