I have installed Artifactory and Jira Plugin to my Jenkins build. Added required tags and I see build pushing my artifacts to Artifactory.
I've added rtCollectIssues
section like so:
stage ('Issues Collection') {
steps {
rtCollectIssues (
serverId: "${ENV_ARTIFACTORY_SERVER_ID}",
config: """{
"version": 1,
"issues": {
"trackerName": "JIRA",
"regexp": "(.+-[0-9]+)\\s-\\s(.+)",
"keyGroupIndex": 1,
"summaryGroupIndex": 2,
"trackerUrl": "https://jira.my-company.com",
"aggregate": "true",
"aggregationStatus": "RELEASED"
}
}""",
buildName: "${ENV_JOB_NAME}",
buildNumber: "${ENV_BUILD_NUMBER}"
)
}
}
However I still do not see any issues showing up in Artifactory under Builds:
Yet, it successfully send this data from Jenkins (based on this image below)
How would I add GIT comments so that they are collected and sent to JFrog Artifactory?
EDIT: Jenkinsfile:
pipeline {
agent any
environment {
ENV_BRANCH_NAME = "${env.BRANCH_NAME}"
ENV_BUILD_NUMBER = "${env.BUILD_NUMBER}"
ENV_JOB_NAME = "${env.JOB_NAME.toLowerCase()}"
ENV_ARTIFACTORY_URL = "artifactorydev.mycompany.com:8081"
ENV_ARTIFACTORY_SERVER_ID = "art-01.net"
ENV_ARTIFACTORY_VIRTUAL_REPO = "docker"
ENV_ARTIFACTORY_RELEASE_REPO = "libs-release-local"
ENV_GIT_URL = "https://myserver/_git/hello-world"
}
stages {
stage ('Clone') {
steps {
echo 'Branch Name: ' + "${ENV_BRANCH_NAME}"
echo 'Build Number: ' + "${ENV_BUILD_NUMBER}"
echo 'Job Name: ' + "${ENV_JOB_NAME}"
echo 'Artifactory Url: ' + "http://${ENV_ARTIFACTORY_URL}/artifactory"
echo 'Artifactory ServerId: ' + "${ENV_ARTIFACTORY_SERVER_ID}"
git(
url: "${ENV_GIT_URL}",
credentialsId: '4c81efa2-1d49-4b70-859e-d699c1f618c0',
branch: 'master'
)
}
}
stage ('Artifactory configuration') {
steps {
rtServer (
id: "${ENV_ARTIFACTORY_SERVER_ID}",
url: "http://${ENV_ARTIFACTORY_URL}/artifactory",
credentialsId: 'f8f8918e-0368-4b37-88ed-cf25401fa1e1',
bypassProxy: true
)
}
}
stage('Build Docker Image') {
steps {
echo 'Starting to build docker image'
script {
def dockerfile = 'Dockerfile'
def customImage = docker.build('$ENV_ARTIFACTORY_URL/$ENV_ARTIFACTORY_VIRTUAL_REPO/$ENV_JOB_NAME:$ENV_BUILD_NUMBER', "-f ${dockerfile} .")
}
}
}
stage ('Push To Artifactory') {
steps {
rtDockerPush(
serverId: "${ENV_ARTIFACTORY_SERVER_ID}",
image: "$ENV_ARTIFACTORY_URL/$ENV_ARTIFACTORY_VIRTUAL_REPO/$ENV_JOB_NAME:$ENV_BUILD_NUMBER",
host: 'tcp://localhost:2375',
targetRepo: "$ENV_ARTIFACTORY_VIRTUAL_REPO",
// Attach custom properties to the published artifacts:
properties: 'status=stable'
)
}
}
stage ('Issues Collection') {
steps {
rtCollectIssues (
serverId: "${ENV_ARTIFACTORY_SERVER_ID}",
config: """{
"version": 1,
"issues": {
"trackerName": "JIRA",
"regexp": "(.+-[0-9]+)\\s-\\s(.+)",
"keyGroupIndex": 1,
"summaryGroupIndex": 2,
"trackerUrl": "https://jira.inwk.com",
"aggregate": "true",
"aggregationStatus": "RELEASED"
}
}""",
// You may alternatively provide a path to a config file, instead of the config itself, by setting:
// configPath: '/path/to/config'
buildName: "${ENV_JOB_NAME}",
buildNumber: "${ENV_BUILD_NUMBER}"
)
}
}
stage ('Publish Build Info') {
steps {
rtBuildInfo (
captureEnv: true,
includeEnvPatterns: ['*Env*'],
maxBuilds: 2,
maxDays: 2,
doNotDiscardBuilds: ["3"],
deleteBuildArtifacts: true,
buildName: "${ENV_JOB_NAME}",
buildNumber: "${ENV_BUILD_NUMBER}"
)
rtPublishBuildInfo (
serverId: "${ENV_ARTIFACTORY_SERVER_ID}",
buildName: "${ENV_JOB_NAME}",
buildNumber: "${ENV_BUILD_NUMBER}"
)
}
}
}
}
EDIT (After pipeline was added to question):
The rtBuildInfo
step configures a build info instance. If no name/number is specified, it configures the default build info matching the jenkins job.
When custom build details are provided, a new build info instance is created if a matching one was not created yet. Therefore when creating a new instance, the step should be used before other step that will use that instance.
Therefore, an example of your pipeline would be:
pipeline { agent any
environment {
ENV_BRANCH_NAME = "${env.BRANCH_NAME}"
ENV_BUILD_NUMBER = "${env.BUILD_NUMBER}"
ENV_JOB_NAME = "${env.JOB_NAME.toLowerCase()}"
ENV_ARTIFACTORY_URL = "artifactorydev.mycompany.com:8081"
ENV_ARTIFACTORY_SERVER_ID = "art-01.net"
ENV_ARTIFACTORY_VIRTUAL_REPO = "docker"
ENV_ARTIFACTORY_RELEASE_REPO = "libs-release-local"
ENV_GIT_URL = "https://myserver/_git/hello-world"
}
stages {
stage ('Clone') {
steps {
echo 'Branch Name: ' + "${ENV_BRANCH_NAME}"
echo 'Build Number: ' + "${ENV_BUILD_NUMBER}"
echo 'Job Name: ' + "${ENV_JOB_NAME}"
echo 'Artifactory Url: ' + "http://${ENV_ARTIFACTORY_URL}/artifactory"
echo 'Artifactory ServerId: ' + "${ENV_ARTIFACTORY_SERVER_ID}"
git(
url: "${ENV_GIT_URL}",
credentialsId: '4c81efa2-1d49-4b70-859e-d699c1f618c0',
branch: 'master'
)
}
}
stage ('Artifactory configuration') {
steps {
rtServer (
id: "${ENV_ARTIFACTORY_SERVER_ID}",
url: "http://${ENV_ARTIFACTORY_URL}/artifactory",
credentialsId: 'f8f8918e-0368-4b37-88ed-cf25401fa1e1',
bypassProxy: true
)
}
}
stage ('Configure Build Info') {
steps {
rtBuildInfo (
captureEnv: true,
includeEnvPatterns: ['*Env*'],
maxBuilds: 2,
maxDays: 2,
doNotDiscardBuilds: ["3"],
deleteBuildArtifacts: true,
buildName: "${ENV_JOB_NAME}",
buildNumber: "${ENV_BUILD_NUMBER}"
)
}
}
stage('Build Docker Image') {
steps {
echo 'Starting to build docker image'
script {
def dockerfile = 'Dockerfile'
def customImage = docker.build('$ENV_ARTIFACTORY_URL/$ENV_ARTIFACTORY_VIRTUAL_REPO/$ENV_JOB_NAME:$ENV_BUILD_NUMBER', "-f ${dockerfile} .")
}
}
}
stage ('Push To Artifactory') {
steps {
rtDockerPush(
serverId: "${ENV_ARTIFACTORY_SERVER_ID}",
image: "$ENV_ARTIFACTORY_URL/$ENV_ARTIFACTORY_VIRTUAL_REPO/$ENV_JOB_NAME:$ENV_BUILD_NUMBER",
host: 'tcp://localhost:2375',
targetRepo: "$ENV_ARTIFACTORY_VIRTUAL_REPO",
// Attach custom properties to the published artifacts:
properties: 'status=stable',
buildName: "${ENV_JOB_NAME}",
buildNumber: "${ENV_BUILD_NUMBER}"
)
}
}
stage ('Issues Collection') {
steps {
rtCollectIssues (
serverId: "${ENV_ARTIFACTORY_SERVER_ID}",
config: """{
"version": 1,
"issues": {
"trackerName": "JIRA",
"regexp": "(.+-[0-9]+)\\s-\\s(.+)",
"keyGroupIndex": 1,
"summaryGroupIndex": 2,
"trackerUrl": "https://jira.inwk.com",
"aggregate": "true",
"aggregationStatus": "RELEASED"
}
}""",
// You may alternatively provide a path to a config file, instead of the config itself, by setting:
// configPath: '/path/to/config'
buildName: "${ENV_JOB_NAME}",
buildNumber: "${ENV_BUILD_NUMBER}"
)
}
}
stage ('Publish Build Info') {
steps {
rtPublishBuildInfo (
serverId: "${ENV_ARTIFACTORY_SERVER_ID}",
buildName: "${ENV_JOB_NAME}",
buildNumber: "${ENV_BUILD_NUMBER}"
)
}
}
}
}
Note how the rtBuildInfo
step was moved to before any steps using it. I also added the buildName
and buildNumber
fields to the rtDockerPush
step assuming you want the build information also collected for that step.
Now when you see in the log that issues were added, you should also see them in Artifactory as well.
End of EDIT.
How would I add GIT comments so that they are collected and sent to JFrog Artifactory?
The regexp
field in the issues collection config controls which git messages are gathered as issues. From the documentation:
A regular expression used for matching the git commit messages. The expression should include two capturing groups - for the issue key (ID) and the issue summary.
For example, for the following regexp field:
'regexp': '(.+-[0-9]+)\\s-\\s(.+)'
The regular expression matches the commit messages as displayed in the following example:
HAP-1364 - Replace tabs with spaces