I am using the Artifactory Jenkins plugin to publish artifacts using the Generic-Artifactory Integration. I would like to be able to refer to the Artifactory Server URL and Target Repository as variables later on in a build script.
Does Artifactory expose these parameters as accessible variables? If so, what are they?
The only other option I have thought of is creating my own variables using the Environment Variable Injector plugin and referencing those variables in the Artifactory fields.
I would prefer to go with option 1.
Related
Previously we had a single monolith in GitLab repository and we used to build project in Jenkins using Jenkinsfile.
Now we are migrating it into multiple microservices and all reside in same GitLab repository. Is it possible to create pipelines for this type of setup or do we need to have each microservice in separate repository. If it is possible please point me to appropriate resources.
Each microservice can have its own Jenkinsfile, you have to tell to the Jenkins job the path of the Jenkinsfile if it is not located at the root path.
In your pipeline configuration job choose "Pipeline script from SCM" and set the "Script Path".
To only checkout the microservice you need, you can use in the "SCM" then "Additional Behaviours" the "Check out to a sub-directory" (then if the Jenkinsfile is now at the pseudo root path, you won't need to change the default "Script Path").
Yes it is possible to create pipelines to build/test/deploy from a single repository.
Use Declarative Pipeline in Jenkins.
You can have your microservices separated in different directories in a single repo and can build them all using a single pipeline using the stages & dir() option in Jenkinsfile. We're building close to 15 components from a single pipeline and push it to it's relevant artifactory from the same job. You can build non-dependent microservice components parallely too.
Documentation --> Jenkins Pipeline,Jenkinsfile
We are setting up the job to generate executable file by gathering different components (All these tagged) , We need a way to get these components based on the name of the build, I know copy artifacts will do but i would like to put this on script, Is there way (Api or something else) can download archived artifacts? once all these components present it is easy to create a installer
I have tried there are multiple curl and wget commands which accept username and password , But I need something without username and password as script runs on jenkins workspace we dont need to pass the password
If you want to interact with Jenkins via scripts there are two ways:
1. Jenkinspipeline
With Jenkinspipelines you can define the builds with Groovy scripts whereby you can use copyArtifact via the Groovy DSL. Its not actually a script its a build definition defined with a Groovy DSL. This should be the way when a Jenkins Job is gathering stuff from other Jobs.
https://jenkins.io/doc/book/pipeline/
2. Jenkins CLI
With the Jenkins CLI you can interact with Jenkins via a shell script. This should be the way when you want to gather stuff from outside of Jenkins.
https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI
If Jenkins is secured then I think you will have to provide credentials when using the Jenkins CLI. With Jenkinspipelines you don't need credentials, because they are executed in Jenkins. But you need to define permissions on the Jenkins Jobs (or in the Pipelines) so that Jenkins Jobs can access Artifacts of other Jobs. (CopyArtifactPermission)
I have a requirement to access build parameters in my custom Jenkins plugin.
I searched everywhere. But I couldn't find an answer.
How can I access build parameters in my custom Jenkins plugin code?
I have just started trying out Jenkins and Artifactory. I have managed to create a jenkins job that just runs MSBuild to create an .exe. I have also managed to upload this .exe to Artifactory.
What I would now like to do is to be able to add metadata e.g. git commit id, unit test result etc. to the artifacts that I want to load to Artifactory.
In Jenkins I can do that either by including a job configuration or including a filespec .json file.
Is the only way to add properties in the filespec dynamically to create a filespec dynamically? Or is there any other way in Jenkins (perhaps using Artifactory RestAPI) to add properties to the artefact before uploading to Artifactory?
I appreciate all the help I can get.
Thanks!
Sami
What are you using to upload your exe to Artifactory? JFrog CLI? Jenkins artifactory plugin?
Assuming this is the Jenkins Artifactory Plugin, you can use a file spec to define the properties that you want to upload (that is the 'props' element described in https://www.jfrog.com/confluence/display/RTF/Using+File+Specs).
The file spec format supports variables when used with JFrog CLI, the variables defined with --spec-vars (see https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-UploadingFiles), so I imagine that you can also use variables when used from the Jenkins Artifactory plugin...
We have a lot of jenkins jobs (400+). A lot of them are uploading new artifacts to our Artifactory. Most of them are using the Artifactory plugin.
When we use that plugin we can check the 'build browser' in Artifactory.
This will show the jenkins jobs which are uploading artifacts with that plugin. It's clear.
The problem is that we also have some jobs in which case it isn't useful for us to implement the artifactory plugin. Is there a way in Artifactory we can check those jobs?
We want to see from an artifact which is uploaded WITHOUT the artifactory plugin from which jenkins job it's coming from.
Jenkins jobs that use the jfrog cli to upload artifacts can now also publish build info.
From the jfrog cli help
JFROG_CLI_BUILD_NAME
Build name to be used by commands which expect a build name, unless sent as a command argument or option.
JFROG_CLI_BUILD_NUMBER
Build number to be used by commands which expect a build number, unless sent as a command argument or option.
JFROG_CLI_BUILD_PROJECT
Artifactory project key.
JFROG_CLI_BUILD_URL
Sets the CI server build URL in the build-info. The "jfrog rt build-publish" command uses the value of this environment variable, unless the --build-url command option is sent.
Setting these environment vars during the Jenkins job and then calling
jfrog rt build-publish will allow you to connect the jobs to the artifacts.