Automatic SCM configuration not working? - Sonatype Lifecycle & Repository Firewall - Sonatype Community
Automatic SCM configuration not working?
Post by rantoniuk on May 5, 2022
Radek Antoniuk
rantoniuk
We are trying to set up automatic SCM application configuration.
According to the documentation, when this is enabled, when a nexus-iq-cli scan is done, the SCM for that application should be auto-configured, which is not happening.
The organisation is created, the BitBucket SCM and credentials are configured and working on the organisation level. If the application SCM url is configured manually for that application, it works fine. However, when it’s not filled, after nexus-iq-cli scan it’s not populated with the discovered git repository url.
Post by jyoung on May 6, 2022
Justin Young
jyoung
Hey Radek,
Thanks for posting. This looks like it is best serviced by our support team. Please submit a ticket in the support portal and they can help debug what is going wrong with the auto configuration.
Cheers!
Justin Young
Director, Product Management
Post by rantoniuk on May 10, 2022
Radek Antoniuk
rantoniuk
I have managed to resolve this issue by checking the -X debug from nexus-iq-cli.
The problem was in how Bamboo CI system is checking out the git repository. In the logfile I could see:
build [INFO] Discovered repository url 'file:///home/bamboo/build-dir/..........' via jGit
build [DEBUG] Amending source control record for application with id: X with discovered repository URL
build [DEBUG] Making external request: POST https://hostname/api/v2/sourceControl?publicId=X&repositoryUrl=file:%2F%2F%2Fhome%2Fbamboo
As you see, the discovered git remote is using file:/// instead of https:// and that causes the nexus-iq-cli not setting the SCM repository correctly. The workaround is to run in your CI a curl request with the above parameters and repositoryUrl set correctly to https.
Example command:
curl -u user -G --request POST --data-urlencode "publicId=appId" --data-urlencode "repositoryUrl=https://path/to/repo.git" https://hostname/api/v2/sourceControl