Reputation: 379
How can I publish build info when when pushing a npm registry to Artifactory?
I can do it with Maven using these steps
def rtMaven = Artifactory.newMavenBuild()
def buildInfo = rtMaven.run pom: 'maven-example/pom.xml', goals: 'clean install'
Currently I am just using npm publish
But I would like to have Builds info for my tgz files. Is it possible?
Thanks!
Upvotes: 1
Views: 1647
Reputation: 48
here a sample pipeline code doing simple build. The only thouble with this script is that i can't figure out how to fill dependencies informations.
node {
stage('Cleaning') {
deleteDir()
}
stage('Preparing') { // for display purposes
// Get some code from Git
git credentialsId: 'MyGitCredential', url: 'http://gitRepourl/MyGitProject.git'
}
stage('Fetch Dependencies') {
// Run the node build
nodejs(nodeJSInstallationName: 'MyNode', configId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') {
sh 'npm install'
}
}
stage('Build') {
// Run the node build
nodejs(nodeJSInstallationName: 'MyNode', configId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') {
sh 'npm pack'
}
}
stage('Test') {
// Run the node build
nodejs(nodeJSInstallationName: 'MyNode', configId: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa') {
sh 'npm run test'
}
}
stage('Results') {
junit 'test-results.xml' // need to setup karma junit reporter
archive 'myArtefact-*.tgz'
}
stage('Artifactory') {
def uploadSpec = """{
"files": [
{
"pattern": "myArtefact-*.tgz",
"target": "artifactory-npm-repo/myArtefact/"
}
]
}"""
def server = Artifactory.server 'MyArtifactory'
def buildInfo = server.upload(uploadSpec)
buildInfo.retention maxBuilds: 2
server.publishBuildInfo(buildInfo)
}
}
But with this, you've got your build ans artifacts in artifactory
Upvotes: 1