OK, I went a bit further, wrapping scripted pipeline syntax pieces in
script{} pseudo-step, so I actually created this:
stage('Submit the sources to SonarQube') {
environment {
SONAR_SCANNER_OPTS = "-Xmx2G -Xms256m"
}
steps {
script {
def scannerHome = tool 'SonarQube Scanner';
withSonarQubeEnv('SonarQube Local') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
}
But later on I stuck again, because the agent was not able to find the
sonar-scanner, despite properly formed path to it. I fiddled with that a
bit and found, that the path actually existed on the agent only (docker
host), but was never exposed to the container, where the scanner suppose
to be started according to Mr. Jenkins logic (actually I see no point to
start the sonar-scanner from within the container, checkout happens on
the docker host anyway, so firing up the scanner on the docker host
itself would be much more elegant). So I added 'arg' to my dockerfile
part of the pipeline:
agent {
dockerfile {
dir 'ubuntu-xenial-mysql'
args '-v /Jenkins-CI/tools:/Jenkins-CI/tools'
}
}
So the tools would become available not only on 'persistent' docker host
agent machine, but inside the container as well. For now — submission
has been successful, waiting the analysis and if webhook would work.
Cheers,
Kirill