如何在电子邮件正文中获取jenkins构建的控制台日志的内容?
How to get the content of console log of jenkins build in email body?
我正在 运行 通过 Jenkins 使用白源扫描仪对 docker 图像进行扫描。我想获取构建日志的一部分并通过电子邮件发送。我正在搜索特定关键字,例如 'Project name:' 并通过 Jenkins 中的电子邮件分机发送。但是我无法使用 ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} 来做到这一点。它只是在电子邮件中显示空白输出。
代码:
stage('Send Email') {
emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} Regards, DT ''',
subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}
- 我试过这个 ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true},但是结果是空的。
- 我尝试使用 ${BUILD_LOG, maxLines=99, escapeHtml=false},但它显示了电子邮件中的所有日志内容。
- 无法将日志附加到文件。 ${BUILD_LOG, maxLines=99, escapeHtml=false} > log.txt
这是詹金斯日志。
Started by user
[Pipeline] node
Running on DevNode in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] dir
Running in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] stage
[Pipeline] { (WorkSpace CleanUp)
[Pipeline] cleanWs
[WS-CLEANUP] Deleting project workspace...[WS-CLEANUP] done
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Checkout SCM)
[Pipeline] dir
Running in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] sh
[geoshield-dataconnector] Running shell script
Login Succeeded
[Pipeline] sh
[geoshield-dataconnector] Running shell script
+ sudo docker pull registry.abcd/dataconnector:V.1.0.0.0
V.1.0.0.0: Pulling from dataconnector
e7c96db7181b: Already exists
584a4cfc5c76: Pulling fs layer
ec4c1f08eb03: Pulling fs layer
73021472167d: Pulling fs layer
a86ac7fa4ae3: Pulling fs layer
28d2d93bdc6e: Pulling fs layer
a8ff63a747fc: Pulling fs layer
c9fd118fb9fc: Pulling fs layer
a86ac7fa4ae3: Waiting
28d2d93bdc6e: Waiting
a8ff63a747fc: Waiting
c9fd118fb9fc: Waiting
584a4cfc5c76: Verifying Checksum
584a4cfc5c76: Download complete
a86ac7fa4ae3: Verifying Checksum
a86ac7fa4ae3: Download complete
73021472167d: Verifying Checksum
73021472167d: Download complete
28d2d93bdc6e: Verifying Checksum
28d2d93bdc6e: Download complete
c9fd118fb9fc: Verifying Checksum
c9fd118fb9fc: Download complete
a8ff63a747fc: Verifying Checksum
a8ff63a747fc: Download complete
584a4cfc5c76: Pull complete
ec4c1f08eb03: Verifying Checksum
ec4c1f08eb03: Download complete
ec4c1f08eb03: Pull complete
73021472167d: Pull complete
a86ac7fa4ae3: Pull complete
28d2d93bdc6e: Pull complete
a8ff63a747fc: Pull complete
c9fd118fb9fc: Pull complete
Digest: sha256:cf62e8ba5a8a499b4a0e421a861511f7485304842ecac7de59d5a463fdab18e5
Status: Downloaded newer image for registry.abcd/dataconnector:V.1.0.0.0
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Fabric OSS scanning)
Running in /home/cyberadmin/workspace/scanner/geoshield-oss
[Pipeline] dir
[Pipeline] {
[Pipeline] git
> git rev-parse --is-inside-work-tree # timeout=10
+ sudo chmod 755 wss-unified-agent-19.7.2.jar
[Pipeline] sh
[geoshield-oss] Running shell script
+ java -jar wss-unified-agent-19.7.2.jar -c dataconnector-image.config -d /opt/Whitesource/Apps/geoshield_images/geoshield-dataconnector -product Fabric -project engine-14
[INFO] [2019-09-30 13:37:58,361 +0530] -
------------------------------------------------------------------------
-------------------- Start: Fetch Configuration ------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:58,409 +0530] - UnifiedAgent version (pluginVersion) : 19.7.2
[INFO] [2019-09-30 13:37:58,438 +0530] - UA Configuration {
DEFAULT_TIMEOUT_PROCESS_MINUTES=15
failErrorLevel=DEFAULT
projectPerFolder=false
connectionTimeOut=60
checkPolicies=true
serviceUrl=https://app-eu.whitesourcesoftware.com/agent
forceCheckAllDependencies=true
forceUpdate=true
forceUpdateFailBuildOnPolicyViolation=false
updateTypeValue=OVERRIDE
enableImpactAnalysis=false
updateInventory=true
generateScanReport=false
scanReportTimeoutMinutes=10
analyzeFrameworks=false
analyzeFrameworkReference=analyzeFrameworks.txt
updateEmptyProject=true
euaOffline=
euaDep=euaDep.json
euaVul=euaVul.json
euaRes=euaRes.json
offline=false
zip=false
prettyJson=true
resolveAllDependencies=false
ignoreSourceFiles=false
appPath=null
cargoResolveDependencies=false
cargoRunPreStep=false
cargoIgnoreSourceFiles=true
npm: {npmRunPreStep=false, npmIgnoreScripts=false, npmResolveDependencies=false, npmIncludeDevDependencies=false, npmTimeoutDependenciesCollector=60, npmIgnoreNpmLsErrors=false, npmYarnProject=false, npmYarnFrozenLockfile=false, npmIgnoreSourceFiles=true, npmIdentifyByNameAndVersion=false, npmResolveMainPackageJsonOnly=false, npmProjectNameFromDependencyFile=false, npmRemoveDuplicateDependencies=true, npmResolveAdditionalDependencies=false}
bower: {bowerResolveDependencies=false, bowerRunPreStep=false, bowerIgnoreSourceFiles=false}
nuget: {nugetResolveDependencies=false, nugetRestoreDependencies=false, nugetRunPreStep=false, nugetIgnoreSourceFiles=true, nugetResolvePackagesConfigFiles=true, nugetResolveCsProjFiles=true, nugetResolveNuspecFiles=true, nugetPreferredEnvironment=, nugetPackagesDirectory=}
ant: {antResolveDependencies=false, antPathidIncludes=, antExternalParameters=}
maven: {mavenResolveDependencies=false, mavenIgnoredScopes=, mavenAggregateModules=false, mavenIgnorePomModules=true, mavenIgnoreSourceFiles=true, mavenRunPreStep=false, mavenIgnoreDependencyTreeErrors=false, mavenEnvironmentPath=, mavenM2Path=, mavenDownloadMissingDependencies=true, mavenAdditionalArguments=}
python: {pythonResolveDependencies=false, pipPath=pip, pythonPath=python, pythonIgnorePipInstallErrors=false, pythonInstallVirtualenv=false, pythonResolveHierarchyTree=true, pythonRequirementsFileIncludes=requirements.txt,Pipfile, pythonResolveSetupPyFiles=false, pythonIgnoreSourceFiles=true, ignorePipEnvInstallErrors=false, pipenvInstallDevDependencies=false, pythonIndexUrl=, runPipenvPreStep=false, pythonIsWssPluginInstalled=false, pythonUninstallWssPlugin=false}
gradle: {gradleResolveDependencies=false, gradleRunAssembleCommand=true, gradleAggregateModules=false, gradlePreferredEnvironment=gradle, gradleLocalRepositoryPath=, gradleAdditionalArguments=, gradleIncludeScopes=, gradleBuildFileIncludes=, gradleIgnoreSourceFiles=false, gradleRunPreStep=false, gradleIgnoredScopes=, gradleDownloadMissingDependencies=true, gradleWrapperPath=}
paket: {paketResolveDependencies=false, paketIgnoredScopes=, paketRunPreStep=false, paketPath=, paketIgnoreSourceFiles=true}
go: {goResolveDependencies=false, goDependencyManager=, goCollectDependenciesAtRuntime=false, goGlideIgnoreTestPackages=true, goIgnoreSourceFiles=false, goGradleEnableTaskAlias=false}
ruby: {rubyResolveDependencies=false, rubyRunBundleInstall=false, rubyOverwriteGemFile=false, rubyInstallMissingGems=false, rubyIgnoreSourceFiles=true}
php: {phpResolveDependencies=false, phpRunPreStep=false, phpIncludeDevDependencies=false}
sbt: {sbtResolveDependencies=false, sbtAggregateModules=false, sbtRunPreStep=false, sbtTargetFolder=, sbtIgnoreSourceFiles=false}
html: {htmlResolveDependencies=false}
cocoapods: {cocoapodsResolveDependencies=false, cocoapodsRunPreStep=false, cocoapodsIgnoreSourceFiles=true}
hex: {hexResolveDependencies=false, hexRunPreStep=false, hexAggregateModules=false, hexIgnoreSourceFiles=true}
r: {rResolveDependencies=false, rRunPreStep=false, rIgnoreSourceFiles=true, rCranMirrorUrl=}
bazel: {bazelResolveDependencies=false, bazelRunPreStep=false}
imageNames=
imageTags=
imageDigests=
forceDelete=false
remoteDockerEnabled=false
maxScanImages=0
forcePull=false
maxPullImages=10
loginSudo=true
defaultamazonRegistryIds=
remoteDockerAmazonEnabled=false
amazonRegion=east
amazonMaxPullImages=0
remoteDockerAzureEnabled=false
azureUserName=
azureUserPassword=
azureRegistryNames=
remoteDockerArtifactoryEnabled=false
dockerArtifactoryUrl=
dockerArtifactoryUserName=
dockerArtifactoryUserPassword=
dockerArtifactoryRepositoryNames=
dockerArtifactoryDockerAccessMethod=
remoteDockerGoogleContainerEnabled=false
googleRepositoryNames=
googleActiveAccount=
remoteDockerHubEnabled=false
dockerHubUserName=
dockerHubUserPassword=
dockerHubOrganizationsNames=
dockerHubAccessToken=
serverlessConfiguration=
fileListPath=
dependencyDirs=Whitesource/Apps/geoshield_images/geoshield-dataconnector
configFilePath=dataconnector-image.config
includes=**/*.jar,**/*.js,**/*.ts,**/*.deb,**/*.tgz,**/*.py,**/*.dll,**/*.apk
excludes=**/*sources.jar,**/*javadoc.jar,**/*pom.xml,**/*build.gradle
dockerIncludes=.*dataconnector.*
dockerExcludes=
dockerContainerIncludes=.*.*
dockerContainerExcludes=
pythonRequirementsFileIncludes=requirements.txt
archiveExtractionDepth=7
archiveIncludes=**/*.jar
archiveExcludes=
followSymbolicLinks=true
globCaseSensitive=false
projectPerFolderIncludes=*
projectPerFolderExcludes=
failErrorLevel=DEFAULT
excludeDependenciesFromNodes=
enableGenerateProjectDetailsJson=false
artifactoryUrl=
artifactoryRepoKeys=
apiToken=******
userKey=
projectVersion=
projectToken=
projectPerSubFolder=false
requesterEmail=
productToken=
productName=Fabric
productVersion=
projectName=unityengine-14
scanComment=
requireKnownSha1=true
scanReportFileNameFormat=project_with_timestamp
artifactoryEnableScan=false
scanPackageManager=false
scanDockerImages=true
scanDockerContainers=false
scanServerlessFunctions=false
logLevel=info
logFilesLevel=DEBUG
logFilesMaxFileSize=10
logFilesMaxFilesCount=3
}
[INFO] [2019-09-30 13:37:58,438 +0530] -
------------------------------------------------------------------------
-------------------- End: Fetch Configuration --------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:58,450 +0530] -
------------------------------------------------------------------------
-------------------- Start: Docker Resolver Scan -----------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:59,277 +0530] - Filtering docker list by includes and excludes lists
[INFO] [2019-09-30 13:37:59,285 +0530] - Handle 1 docker entities
[INFO] [2019-09-30 13:37:59,285 +0530] - Image 1 of 1
[INFO] [2019-09-30 13:38:04,628 +0530] - Extracting file /tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd-dataconnector.tar - Size 185261568 Bytes (176 MBs)- Free Space 31528574976 Bytes (30067 MBs)
[INFO] [2019-09-30 13:38:06,566 +0530] - Found 50 system packages in image 'registry.abcd/dataconnector'
[INFO] [2019-09-30 13:38:06,577 +0530] - Starting Archive Extraction (may take a few minutes)
[INFO] [2019-09-30 13:38:06,849 +0530] - Starting analysis
[INFO] [2019-09-30 13:38:06,849 +0530] - Scanning directories [/tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd-dataconnector] for package dependencies (may take a few minutes)
[INFO] [2019-09-30 13:38:06,849 +0530] - Included file types: **/*.jar,**/*.js,**/*.ts,**/*.deb,**/*.tgz,**/*.py,**/*.dll,**/*.apk
[INFO] [2019-09-30 13:38:06,849 +0530] - Excluded file types: **/*sources.jar,**/*javadoc.jar,**/*pom.xml,**/*build.gradle
[INFO] [2019-09-30 13:38:06,849 +0530] -
------------------------------------------------------------------------
-------------------- Start: Scan Files Matching Includes Pattern -------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:06,949 +0530] - Scanning directories [/tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd/dataconnector] for matching source/binary file types (may take a few minutes)
[INFO] [2019-09-30 13:38:07,376 +0530] - Total files found according to the includes/excludes pattern: 399
------------------------------------------------------------------------
-------------------- End: Scan Files Matching Includes Pattern ---------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,197 +0530] - Finished analyzing Files
[INFO] [2019-09-30 13:38:12,365 +0530] -
------------------------------------------------------------------------
-------------------- End: Docker Resolver Scan -------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,374 +0530] - Initializing WhiteSource Client
[INFO] [2019-09-30 13:38:12,376 +0530] - Service URL is https://app-eu.whitesourcesoftware.com/agent
[INFO] [2019-09-30 13:38:12,430 +0530] - UpdateType set to OVERRIDE
[INFO] [2019-09-30 13:38:12,433 +0530] -
------------------------------------------------------------------------
-------------------- Start: Check Policies -----------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,433 +0530] - Checking policies
[INFO] [2019-09-30 13:38:19,225 +0530] - Some dependencies violate open source policies, however all were force updated to organization inventory.
[INFO] [2019-09-30 13:38:20,161 +0530] - Check Policies Support Token: 399b1607baf0b46d5ab370883736896d01569830894289
[INFO] [2019-09-30 13:38:20,404 +0530] - Policies report generated successfully
[INFO] [2019-09-30 13:38:20,404 +0530] -
------------------------------------------------------------------------
-------------------- End: Check Policies -------------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:20,404 +0530] - Sending Update
[INFO] [2019-09-30 13:38:20,405 +0530] -
------------------------------------------------------------------------
-------------------- Start: Update Inventory ---------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:21,556 +0530] -
------------------------------------------------------------------------
-------------------- End: Update Inventory -----------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:21,556 +0530] -
[INFO] [2019-09-30 13:38:21,556 +0530] - No new projects found.
[INFO] [2019-09-30 13:38:21,556 +0530] - Updated projects:
[INFO] [2019-09-30 13:38:21,556 +0530] - # registry.abcd/dataconnector V.1.0.0.0 (7afaac1a588a)
[INFO] [2019-09-30 13:38:21,557 +0530] - Project name: registry.abcd/dataconnector V.1.0.0.0 (7afaac1a588a), URL: https://app-eu.whitesourcesoftware.com/Wss/WSS.html#!project;id=295252
[INFO] [2019-09-30 13:38:21,557 +0530] - Support Token: 2c5caed97ddad4fde8b085ee5c83484c71569830900960
[INFO] [2019-09-30 13:38:21,730 +0530] -
------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------- WhiteSource Scan Summary: --------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
======================================================================================================================================================
Scan Origin: Local Docker Images
======================================================================================================================================================
Step Completion Status Elapsed Comments
======================================================================================================================================================
Fetch Configuration COMPLETED 00:00:00.079 --------
Scan Files Matching Includes Pattern COMPLETED 00:00:04.918 399 source/binary files
dll COMPLETED -------- 399 source/binary files
Docker Resolver Scan COMPLETED 00:00:13.080 --------
image-tag-sha256 COMPLETED 00:00:13.080 registry.abcd/dataconnector-V.1.0.0.0-7afaac1a588a
alpine COMPLETED -------- 50 packages
Check Policies COMPLETED 00:00:07.971 --------
Update Inventory COMPLETED 00:00:01.151 1 updated projects
[Pipeline] { (Send Email)
[Pipeline] emailext
Sending email to:
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
我希望通过电子邮件分机在电子邮件正文中显示以下行。
项目名称:注册表。abcd/dataconnector V.1.0.0.0 (7afaac1a588a),URL:https://app-eu.whitesourcesoftware.com/Wss/WSS.html#!project;id=295252
如果您 post 调用 emailext 的代码部分会很有帮助。下面的示例按预期对我有效,其中我有一个进程将字符串 "Hostname" 之后的主机名打印到构建日志中。
电子邮件扩展插件 v2.66
stage('Email the results') {
emailext attachLog: true,
attachmentsPattern: '*',
to: "Me@Somewhere.com",
subject: "Result: ${currentBuild.currentResult}",
body: '''
Body
${BUILD_LOG_REGEX, regex="Hostname", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}
'''
}
针对您的代码的解决方案,删除插入符号^
stage('Send Email') {
emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex="Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} Regards, DT ''',
subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}
下一个问题是删除之前的所有内容 "Project name:" - 括号中的所有内容都代表“$1”,我们将使用 substText=" 将这一行替换为“$1”的内容$1"
stage('Send Email') {
emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex=".*(Project name:.*)", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true, substText=""} Regards, DT ''',
subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}
我正在 运行 通过 Jenkins 使用白源扫描仪对 docker 图像进行扫描。我想获取构建日志的一部分并通过电子邮件发送。我正在搜索特定关键字,例如 'Project name:' 并通过 Jenkins 中的电子邮件分机发送。但是我无法使用 ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} 来做到这一点。它只是在电子邮件中显示空白输出。
代码:
stage('Send Email') {
emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} Regards, DT ''',
subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}
- 我试过这个 ${BUILD_LOG_REGEX, regex="^Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true},但是结果是空的。
- 我尝试使用 ${BUILD_LOG, maxLines=99, escapeHtml=false},但它显示了电子邮件中的所有日志内容。
- 无法将日志附加到文件。 ${BUILD_LOG, maxLines=99, escapeHtml=false} > log.txt
这是詹金斯日志。
Started by user
[Pipeline] node
Running on DevNode in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] dir
Running in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] stage
[Pipeline] { (WorkSpace CleanUp)
[Pipeline] cleanWs
[WS-CLEANUP] Deleting project workspace...[WS-CLEANUP] done
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Checkout SCM)
[Pipeline] dir
Running in /home/cyberadmin/workspace/Whitesource/Apps/geoshield_images/geoshield-dataconnector
[Pipeline] {
[Pipeline] sh
[geoshield-dataconnector] Running shell script
Login Succeeded
[Pipeline] sh
[geoshield-dataconnector] Running shell script
+ sudo docker pull registry.abcd/dataconnector:V.1.0.0.0
V.1.0.0.0: Pulling from dataconnector
e7c96db7181b: Already exists
584a4cfc5c76: Pulling fs layer
ec4c1f08eb03: Pulling fs layer
73021472167d: Pulling fs layer
a86ac7fa4ae3: Pulling fs layer
28d2d93bdc6e: Pulling fs layer
a8ff63a747fc: Pulling fs layer
c9fd118fb9fc: Pulling fs layer
a86ac7fa4ae3: Waiting
28d2d93bdc6e: Waiting
a8ff63a747fc: Waiting
c9fd118fb9fc: Waiting
584a4cfc5c76: Verifying Checksum
584a4cfc5c76: Download complete
a86ac7fa4ae3: Verifying Checksum
a86ac7fa4ae3: Download complete
73021472167d: Verifying Checksum
73021472167d: Download complete
28d2d93bdc6e: Verifying Checksum
28d2d93bdc6e: Download complete
c9fd118fb9fc: Verifying Checksum
c9fd118fb9fc: Download complete
a8ff63a747fc: Verifying Checksum
a8ff63a747fc: Download complete
584a4cfc5c76: Pull complete
ec4c1f08eb03: Verifying Checksum
ec4c1f08eb03: Download complete
ec4c1f08eb03: Pull complete
73021472167d: Pull complete
a86ac7fa4ae3: Pull complete
28d2d93bdc6e: Pull complete
a8ff63a747fc: Pull complete
c9fd118fb9fc: Pull complete
Digest: sha256:cf62e8ba5a8a499b4a0e421a861511f7485304842ecac7de59d5a463fdab18e5
Status: Downloaded newer image for registry.abcd/dataconnector:V.1.0.0.0
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Fabric OSS scanning)
Running in /home/cyberadmin/workspace/scanner/geoshield-oss
[Pipeline] dir
[Pipeline] {
[Pipeline] git
> git rev-parse --is-inside-work-tree # timeout=10
+ sudo chmod 755 wss-unified-agent-19.7.2.jar
[Pipeline] sh
[geoshield-oss] Running shell script
+ java -jar wss-unified-agent-19.7.2.jar -c dataconnector-image.config -d /opt/Whitesource/Apps/geoshield_images/geoshield-dataconnector -product Fabric -project engine-14
[INFO] [2019-09-30 13:37:58,361 +0530] -
------------------------------------------------------------------------
-------------------- Start: Fetch Configuration ------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:58,409 +0530] - UnifiedAgent version (pluginVersion) : 19.7.2
[INFO] [2019-09-30 13:37:58,438 +0530] - UA Configuration {
DEFAULT_TIMEOUT_PROCESS_MINUTES=15
failErrorLevel=DEFAULT
projectPerFolder=false
connectionTimeOut=60
checkPolicies=true
serviceUrl=https://app-eu.whitesourcesoftware.com/agent
forceCheckAllDependencies=true
forceUpdate=true
forceUpdateFailBuildOnPolicyViolation=false
updateTypeValue=OVERRIDE
enableImpactAnalysis=false
updateInventory=true
generateScanReport=false
scanReportTimeoutMinutes=10
analyzeFrameworks=false
analyzeFrameworkReference=analyzeFrameworks.txt
updateEmptyProject=true
euaOffline=
euaDep=euaDep.json
euaVul=euaVul.json
euaRes=euaRes.json
offline=false
zip=false
prettyJson=true
resolveAllDependencies=false
ignoreSourceFiles=false
appPath=null
cargoResolveDependencies=false
cargoRunPreStep=false
cargoIgnoreSourceFiles=true
npm: {npmRunPreStep=false, npmIgnoreScripts=false, npmResolveDependencies=false, npmIncludeDevDependencies=false, npmTimeoutDependenciesCollector=60, npmIgnoreNpmLsErrors=false, npmYarnProject=false, npmYarnFrozenLockfile=false, npmIgnoreSourceFiles=true, npmIdentifyByNameAndVersion=false, npmResolveMainPackageJsonOnly=false, npmProjectNameFromDependencyFile=false, npmRemoveDuplicateDependencies=true, npmResolveAdditionalDependencies=false}
bower: {bowerResolveDependencies=false, bowerRunPreStep=false, bowerIgnoreSourceFiles=false}
nuget: {nugetResolveDependencies=false, nugetRestoreDependencies=false, nugetRunPreStep=false, nugetIgnoreSourceFiles=true, nugetResolvePackagesConfigFiles=true, nugetResolveCsProjFiles=true, nugetResolveNuspecFiles=true, nugetPreferredEnvironment=, nugetPackagesDirectory=}
ant: {antResolveDependencies=false, antPathidIncludes=, antExternalParameters=}
maven: {mavenResolveDependencies=false, mavenIgnoredScopes=, mavenAggregateModules=false, mavenIgnorePomModules=true, mavenIgnoreSourceFiles=true, mavenRunPreStep=false, mavenIgnoreDependencyTreeErrors=false, mavenEnvironmentPath=, mavenM2Path=, mavenDownloadMissingDependencies=true, mavenAdditionalArguments=}
python: {pythonResolveDependencies=false, pipPath=pip, pythonPath=python, pythonIgnorePipInstallErrors=false, pythonInstallVirtualenv=false, pythonResolveHierarchyTree=true, pythonRequirementsFileIncludes=requirements.txt,Pipfile, pythonResolveSetupPyFiles=false, pythonIgnoreSourceFiles=true, ignorePipEnvInstallErrors=false, pipenvInstallDevDependencies=false, pythonIndexUrl=, runPipenvPreStep=false, pythonIsWssPluginInstalled=false, pythonUninstallWssPlugin=false}
gradle: {gradleResolveDependencies=false, gradleRunAssembleCommand=true, gradleAggregateModules=false, gradlePreferredEnvironment=gradle, gradleLocalRepositoryPath=, gradleAdditionalArguments=, gradleIncludeScopes=, gradleBuildFileIncludes=, gradleIgnoreSourceFiles=false, gradleRunPreStep=false, gradleIgnoredScopes=, gradleDownloadMissingDependencies=true, gradleWrapperPath=}
paket: {paketResolveDependencies=false, paketIgnoredScopes=, paketRunPreStep=false, paketPath=, paketIgnoreSourceFiles=true}
go: {goResolveDependencies=false, goDependencyManager=, goCollectDependenciesAtRuntime=false, goGlideIgnoreTestPackages=true, goIgnoreSourceFiles=false, goGradleEnableTaskAlias=false}
ruby: {rubyResolveDependencies=false, rubyRunBundleInstall=false, rubyOverwriteGemFile=false, rubyInstallMissingGems=false, rubyIgnoreSourceFiles=true}
php: {phpResolveDependencies=false, phpRunPreStep=false, phpIncludeDevDependencies=false}
sbt: {sbtResolveDependencies=false, sbtAggregateModules=false, sbtRunPreStep=false, sbtTargetFolder=, sbtIgnoreSourceFiles=false}
html: {htmlResolveDependencies=false}
cocoapods: {cocoapodsResolveDependencies=false, cocoapodsRunPreStep=false, cocoapodsIgnoreSourceFiles=true}
hex: {hexResolveDependencies=false, hexRunPreStep=false, hexAggregateModules=false, hexIgnoreSourceFiles=true}
r: {rResolveDependencies=false, rRunPreStep=false, rIgnoreSourceFiles=true, rCranMirrorUrl=}
bazel: {bazelResolveDependencies=false, bazelRunPreStep=false}
imageNames=
imageTags=
imageDigests=
forceDelete=false
remoteDockerEnabled=false
maxScanImages=0
forcePull=false
maxPullImages=10
loginSudo=true
defaultamazonRegistryIds=
remoteDockerAmazonEnabled=false
amazonRegion=east
amazonMaxPullImages=0
remoteDockerAzureEnabled=false
azureUserName=
azureUserPassword=
azureRegistryNames=
remoteDockerArtifactoryEnabled=false
dockerArtifactoryUrl=
dockerArtifactoryUserName=
dockerArtifactoryUserPassword=
dockerArtifactoryRepositoryNames=
dockerArtifactoryDockerAccessMethod=
remoteDockerGoogleContainerEnabled=false
googleRepositoryNames=
googleActiveAccount=
remoteDockerHubEnabled=false
dockerHubUserName=
dockerHubUserPassword=
dockerHubOrganizationsNames=
dockerHubAccessToken=
serverlessConfiguration=
fileListPath=
dependencyDirs=Whitesource/Apps/geoshield_images/geoshield-dataconnector
configFilePath=dataconnector-image.config
includes=**/*.jar,**/*.js,**/*.ts,**/*.deb,**/*.tgz,**/*.py,**/*.dll,**/*.apk
excludes=**/*sources.jar,**/*javadoc.jar,**/*pom.xml,**/*build.gradle
dockerIncludes=.*dataconnector.*
dockerExcludes=
dockerContainerIncludes=.*.*
dockerContainerExcludes=
pythonRequirementsFileIncludes=requirements.txt
archiveExtractionDepth=7
archiveIncludes=**/*.jar
archiveExcludes=
followSymbolicLinks=true
globCaseSensitive=false
projectPerFolderIncludes=*
projectPerFolderExcludes=
failErrorLevel=DEFAULT
excludeDependenciesFromNodes=
enableGenerateProjectDetailsJson=false
artifactoryUrl=
artifactoryRepoKeys=
apiToken=******
userKey=
projectVersion=
projectToken=
projectPerSubFolder=false
requesterEmail=
productToken=
productName=Fabric
productVersion=
projectName=unityengine-14
scanComment=
requireKnownSha1=true
scanReportFileNameFormat=project_with_timestamp
artifactoryEnableScan=false
scanPackageManager=false
scanDockerImages=true
scanDockerContainers=false
scanServerlessFunctions=false
logLevel=info
logFilesLevel=DEBUG
logFilesMaxFileSize=10
logFilesMaxFilesCount=3
}
[INFO] [2019-09-30 13:37:58,438 +0530] -
------------------------------------------------------------------------
-------------------- End: Fetch Configuration --------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:58,450 +0530] -
------------------------------------------------------------------------
-------------------- Start: Docker Resolver Scan -----------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:37:59,277 +0530] - Filtering docker list by includes and excludes lists
[INFO] [2019-09-30 13:37:59,285 +0530] - Handle 1 docker entities
[INFO] [2019-09-30 13:37:59,285 +0530] - Image 1 of 1
[INFO] [2019-09-30 13:38:04,628 +0530] - Extracting file /tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd-dataconnector.tar - Size 185261568 Bytes (176 MBs)- Free Space 31528574976 Bytes (30067 MBs)
[INFO] [2019-09-30 13:38:06,566 +0530] - Found 50 system packages in image 'registry.abcd/dataconnector'
[INFO] [2019-09-30 13:38:06,577 +0530] - Starting Archive Extraction (may take a few minutes)
[INFO] [2019-09-30 13:38:06,849 +0530] - Starting analysis
[INFO] [2019-09-30 13:38:06,849 +0530] - Scanning directories [/tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd-dataconnector] for package dependencies (may take a few minutes)
[INFO] [2019-09-30 13:38:06,849 +0530] - Included file types: **/*.jar,**/*.js,**/*.ts,**/*.deb,**/*.tgz,**/*.py,**/*.dll,**/*.apk
[INFO] [2019-09-30 13:38:06,849 +0530] - Excluded file types: **/*sources.jar,**/*javadoc.jar,**/*pom.xml,**/*build.gradle
[INFO] [2019-09-30 13:38:06,849 +0530] -
------------------------------------------------------------------------
-------------------- Start: Scan Files Matching Includes Pattern -------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:06,949 +0530] - Scanning directories [/tmp/WhiteSource-Docker_dad7200b-b049-4839-bd89-216ebb37f222/registry.abcd/dataconnector] for matching source/binary file types (may take a few minutes)
[INFO] [2019-09-30 13:38:07,376 +0530] - Total files found according to the includes/excludes pattern: 399
------------------------------------------------------------------------
-------------------- End: Scan Files Matching Includes Pattern ---------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,197 +0530] - Finished analyzing Files
[INFO] [2019-09-30 13:38:12,365 +0530] -
------------------------------------------------------------------------
-------------------- End: Docker Resolver Scan -------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,374 +0530] - Initializing WhiteSource Client
[INFO] [2019-09-30 13:38:12,376 +0530] - Service URL is https://app-eu.whitesourcesoftware.com/agent
[INFO] [2019-09-30 13:38:12,430 +0530] - UpdateType set to OVERRIDE
[INFO] [2019-09-30 13:38:12,433 +0530] -
------------------------------------------------------------------------
-------------------- Start: Check Policies -----------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:12,433 +0530] - Checking policies
[INFO] [2019-09-30 13:38:19,225 +0530] - Some dependencies violate open source policies, however all were force updated to organization inventory.
[INFO] [2019-09-30 13:38:20,161 +0530] - Check Policies Support Token: 399b1607baf0b46d5ab370883736896d01569830894289
[INFO] [2019-09-30 13:38:20,404 +0530] - Policies report generated successfully
[INFO] [2019-09-30 13:38:20,404 +0530] -
------------------------------------------------------------------------
-------------------- End: Check Policies -------------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:20,404 +0530] - Sending Update
[INFO] [2019-09-30 13:38:20,405 +0530] -
------------------------------------------------------------------------
-------------------- Start: Update Inventory ---------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:21,556 +0530] -
------------------------------------------------------------------------
-------------------- End: Update Inventory -----------------------------
------------------------------------------------------------------------
[INFO] [2019-09-30 13:38:21,556 +0530] -
[INFO] [2019-09-30 13:38:21,556 +0530] - No new projects found.
[INFO] [2019-09-30 13:38:21,556 +0530] - Updated projects:
[INFO] [2019-09-30 13:38:21,556 +0530] - # registry.abcd/dataconnector V.1.0.0.0 (7afaac1a588a)
[INFO] [2019-09-30 13:38:21,557 +0530] - Project name: registry.abcd/dataconnector V.1.0.0.0 (7afaac1a588a), URL: https://app-eu.whitesourcesoftware.com/Wss/WSS.html#!project;id=295252
[INFO] [2019-09-30 13:38:21,557 +0530] - Support Token: 2c5caed97ddad4fde8b085ee5c83484c71569830900960
[INFO] [2019-09-30 13:38:21,730 +0530] -
------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------- WhiteSource Scan Summary: --------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
======================================================================================================================================================
Scan Origin: Local Docker Images
======================================================================================================================================================
Step Completion Status Elapsed Comments
======================================================================================================================================================
Fetch Configuration COMPLETED 00:00:00.079 --------
Scan Files Matching Includes Pattern COMPLETED 00:00:04.918 399 source/binary files
dll COMPLETED -------- 399 source/binary files
Docker Resolver Scan COMPLETED 00:00:13.080 --------
image-tag-sha256 COMPLETED 00:00:13.080 registry.abcd/dataconnector-V.1.0.0.0-7afaac1a588a
alpine COMPLETED -------- 50 packages
Check Policies COMPLETED 00:00:07.971 --------
Update Inventory COMPLETED 00:00:01.151 1 updated projects
[Pipeline] { (Send Email)
[Pipeline] emailext
Sending email to:
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
我希望通过电子邮件分机在电子邮件正文中显示以下行。
项目名称:注册表。abcd/dataconnector V.1.0.0.0 (7afaac1a588a),URL:https://app-eu.whitesourcesoftware.com/Wss/WSS.html#!project;id=295252
如果您 post 调用 emailext 的代码部分会很有帮助。下面的示例按预期对我有效,其中我有一个进程将字符串 "Hostname" 之后的主机名打印到构建日志中。
电子邮件扩展插件 v2.66
stage('Email the results') {
emailext attachLog: true,
attachmentsPattern: '*',
to: "Me@Somewhere.com",
subject: "Result: ${currentBuild.currentResult}",
body: '''
Body
${BUILD_LOG_REGEX, regex="Hostname", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}
'''
}
针对您的代码的解决方案,删除插入符号^
stage('Send Email') {
emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex="Project name:", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true} Regards, DT ''',
subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}
下一个问题是删除之前的所有内容 "Project name:" - 括号中的所有内容都代表“$1”,我们将使用 substText=" 将这一行替换为“$1”的内容$1"
stage('Send Email') {
emailext body: '''Hi, Please find below. ${BUILD_LOG_REGEX, regex=".*(Project name:.*)", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true, substText=""} Regards, DT ''',
subject: 'Test - Build ${BUILD_STATUS} - Build #${BUILD_NUMBER}', to: 'justin.xavier@abcd.com'
}