Closed puash closed 3 years ago
Hi @puash,
First of all, I apologize for taking so long answering this. Somehow I though I already replied.
There is an example showing a Jenkins configuration at https://github.com/guillermo-varela/example-scan-gradle-plugin#nexus-iq-server-1
Credentials in that example are stored in the credentials configuration in Jenkins. There are links there expanding more on that topic.
Could you please give it a try and see if that works in your Jenkins instance (rather than passing the values as parameters)?
Hi @puash,
I was able to get another round to look at this and found an issue with our documentation regarding environment variables.
It turns out the -D flag doesn't set environment variables but instead it's for system properties so I updated the readme file to specify how that can be used: https://github.com/sonatype-nexus-community/scan-gradle-plugin#sensitive-data
Testing the plugin in a local Jenkins instances I got this working:
nexusIQScan {
username = project['username']
password = project['password']
serverUrl = project['serverUrl']
applicationId = project['appID']
stage = project['stage']
}
pipeline {
agent any
tools {
jdk 'OpenJDK 8'
}
stages {
stage('Nexus IQ Scan') {
steps {
sh './gradlew nexusIQScan -Pusername=admin -Ppassword=passw -PserverUrl=http://localhost:8070 -PappID=app1 -Pstage=build'
}
}
}
}
nexusIQScan {
username = System.properties['username']
password = System.properties['password']
serverUrl = System.properties['serverUrl']
applicationId = System.properties['appID']
stage = System.properties['stage']
}
pipeline {
agent any
tools {
jdk 'OpenJDK 8'
}
stages {
stage('Nexus IQ Scan') {
steps {
sh './gradlew nexusIQScan -Dusername=admin -Dpassword=admin123 -DserverUrl=http://localhost:8070 -DappID=app1 -Dstage=build'
}
}
}
}
nexusIQScan {
username = System.getenv('IQ_CREDENTIALS_USR')
password = System.getenv('IQ_CREDENTIALS_PSW')
serverUrl = 'http://localhost:8070'
applicationId = 'app1'
}
pipeline {
agent any
tools {
jdk 'OpenJDK 8'
}
stages {
stage('Nexus IQ Scan') {
environment {
IQ_CREDENTIALS = credentials('iq.credentials')
}
steps {
sh './gradlew nexusIQScan'
}
}
}
}
Thank you for bringing this to our attention, it allowed us to understand better how to pass parameters to our plugin and hopefully other users find our updated documentations easier to follow :)
Closing due to inactivity. If the issue continues, feel free to open a new issue.
Describe the bug Not able to use the project properties (-P arguments) or environment variables (-D arguments or injected from a tool) for nexusIQScan plugin.
Error logs:
To Reproduce Steps to reproduce the behaviour: My project has 2 gradle.build (one parent and one child)
OR
Expected behavior Able to run the nexusIQ scan without any issues
Desktop (please complete the following information):