How to add additional mysql-connector after installing dependency-check in Jenkins Global Tool Configuration

24 views
Skip to first unread message

Amedee Van Gasse

unread,
Feb 23, 2021, 10:33:48 AM2/23/21
to Jenkins Users
I'm going to use dependency-check on Jenkins to check a .NET build.

I have added a Dependency-Check installation to Jenkins' Global Tool Configuration.
I'm using an install from dl.bintray.com.

In my Jenkins Pipeline, I have:

environment {
    DEPENDENCY_CHECK = tool name: 'Dependency Check', type: 'org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation'
}

and

stage('Dependency Check') {
    steps {
        println 'Dependency Check'
        println DEPENDENCY_CHECK.toString()
    }
}

(Just for now)

Can confirm:
* In the build log I see
Unpacking https://dl.bintray.com/jeremy-long/owasp/dependency-check-6.1.1-release.zip to C:\Jenkins\tools\org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation\Dependency_Check on ********
* In the build log I see  
14:53:23 Dependency Check 
14:53:23 C:\Jenkins\tools\org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation\Dependency_Check
* On the build node, a new directory C:\Jenkins\tools\org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation\Dependency_Check contains the correct files.


Now.

I'm using a local database in MySQL, so I need to put an additional file mysql-connector-java-8.0.22.jar inside a plugins folder in the installation folder.
How do I do that in the Jenkins Global Tool Configuration? If I add a second installer to copy the mysql jar, then it only installs that one single jar file.

Amedee Van Gasse

unread,
Feb 23, 2021, 9:31:20 PM2/23/21
to Jenkins Users
Never mind, I wound up writing an entire batch script directly inside the Jenkins Global Tool Configuration:

if exist C:\Jenkins\tools\org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation\Dependency_Check\dependency-check\bin\dependency-check.bat (
    echo "Dependency Check is already installed"
) else (
    powershell -Command "Invoke-WebRequest https://<ARTIFACTORY_URL>/files/tools/dependency-check/dependency-check-6.1.1-release.zip -OutFile dependency-check-6.1.1-release.zip"
    powershell Expand-Archive 'dependency-check-6.1.1-release.zip' -Force -DestinationPath 'C:\Jenkins\tools\org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation\Dependency_Check'
    powershell -Command "Invoke-WebRequest https://<ARTIFACTORY_URL>/files/tools/dependency-check/mysql-connector-java-8.0.22.jar -OutFile dependency-check/plugins/mysql-connector-java-8.0.22.jar"
    del *.zip
)

It's as ugly as the night, but it works.

If anyone has an idea for a more elegant solution, please enlighten me.
Reply all
Reply to author
Forward
0 new messages