Gradle distribution remote repo - gradle

Does anyone know how to create a remote repo that pulls packages from https://services.gradle.org/distributions/ ?
This post seems to indicate it's possible, but I haven't had any luck.
This post refers to a video with some instructions, but those don't appear to apply to the version we're on (v7.15).
I suspect I probably need a custom layout, but the file names don't seem to play nicely with the parts Artifactory is expecting.
Here is one of my attempts:
and set this in the gradle-wrapper.properties:
distributionUrl=https://<server_name>:443/artifactory/gradle-dist/distributions/gradle-6.8-bin.zip
But it does not work. I'm not able to browse the repo in the Artifactory website nor can I execute the build.

To use Artifactory as a source for Gradle distributions, do the following:
Create a remote generic repository in Artifactory with the URL pointing to https://services.gradle.org/distributions.
Create the Gradle wrapper. As instructed in the Gradle wrapper documentation, you must provide the full URL to the Gradle distibution zip:
gradle wrapper --gradle-distribution-url=<artifactory-url>/gradle-dist/gradle-5.6.4-bin.zip
If authentication is needed, you can add username and password as system properties when running the Gradle commands:
./gradlew --version -Dgradle.wrapperUser=<artifactory-username> -Dgradle.wrapperPassword=<artifactory-password>
Read more:
Artifactory remote repositories
The Gradle wrapper

Related

Jfrog CLI Maven snapshot and release deployments

In our project, we are using maven as the build tool, GitHub actions as the build agent, and Jfrog as the artifactory to deploy the jar files. We have both snapshot and release versions (identified using the "SNAPSHOT" in the version tag in pom). Currently we use the maven deploy plugin to deploy the built artifacts to Jfrog and the details of the repository are configured in the maven settings using the following tags in the maven profile:
When running maven deploy, the deploy plugin builds the project and deploys it to the artifactory and respective repository based on the artifact's version (has "SNAPSHOT" or not). After going through a few documents and blogs such as the following one:
https://jfrog.com/blog/dont-let-maven-deploy-plugin-trip-you
we thought it was better to use the jfrog artifactory plugin to achieve this so that we can capture build info and all among others. Since we are using GitHub actions, I could not find an artifactory plugin that is used for GitHub actions (found one for Jenkins and a few others but not for GitHub actions), I also don't want to add the plugin to my pom file and configure the repository details there as it would tie the repository details in pom. Also, I would like to separate the deploy logic from pom and move it to a CI server, so that these details can be hidden from the developers (the maven deploy plugin does this somewhat as all the artifactory config happens in the maven settings file)
The artifactory plugin can be configured in pom as follows:
referenced from https://www.jfrog.com/confluence/display/JFROG/Maven+Artifactory+Plugin
Then I found that we can use Jfrog CLI in GitHub actions to deploy the artifacts, but I could not find how I can configure the CLI to use both snapshot and release repositories so that I do not have to manually decide where to upload them by using the repo name. Can anybody guide me on how to achieve this in CLI?
I have referred to the following links from GitHub as well as jfrog:
https://github.com/marketplace/actions/setup-jfrog-cli
https://github.com/marketplace/actions/jfrog-cli-for-artifactory
https://jfrog.com/blog/jfrog-cli-github-actions-hero
https://jfrog.com/blog/publishing-binaries-using-the-jfrog-cli
https://jfrog.com/blog/using-the-jfrog-cli-with-github-actions
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
SO, I have finally managed to figure out how this can be done using github actions.
Im my actions.yml file, I have added a new step which makes use of "jfrog/setup-jfrog-cli" action from the github actions marketplace, the link to this is as follows. It shows you how to configure the action.
https://github.com/marketplace/actions/setup-jfrog-cli
I have configured the artifactory platform url as well as the username and access token in this action.
A new action was created which would build my code using the "jf maven" goal. Before you can make use of maven using jfrog CLI, it needs to be configured using the "jf mvn-config" command, it is here that you can specify which are the release and snapshot repositories that you want to make use of. The following is the code snippet that I have used for the same. Please note that these are steps within the github actions pipeline job and not the completed build yml file'
- name: Setup jfrog
uses: jfrog/setup-jfrog-cli#v3
with:
version: latest
env:
JF_URL: "https://artifactory.com" #be mindful not to add the path /artifactory here as it will cause authentication issue
JF_USER: ${{ secrets.ARTIFACT_USER_ID }}
JF_ACCESS_TOKEN: ${{ secrets.ARTIFACT_TOKEN }} # You have an option of giving password as well
- name: maven build
run: |
jf mvn-config --repo-deploy-releases=${ARTIFACTORY_RELEASE} --repo-deploy-snapshots=${ARTIFACTORY_SNAPSHOT} # mention the names of your release and snapshot repos within the jfrog artifacory
jf mvn deploy
jf rt bp # (optional, deploy build info, use --dry-run flag to see the build info in console without committing it)
There are many other optional parameters which you can use to enrich and configure the build, it can be found in the following links
https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-RunningMavenBuilds
https://www.jfrog.com/confluence/display/JFROG/QuickStart+Guide%3A+Maven+and+Gradle
https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-BuildIntegration

How do I setup & use the artifactory features provided by GitLab

I have looked up various Q&A's on how to use the artifactory features offered by GitLab, and they all talk about either JFrog (a.k.a Artifactory) or Nexus or something else. GitLab says that we could use it as Artifact management, and I was able to generate artifacts. But I am stuck now since I am completely lost on how to use this.
Here is the script I use to generate artifact using Gradle:
artifacts:
paths:
- build/libs/*.jar
Can anyone guide me on how I could refer to an artifact in my repo during CI/CD. Thanks in advance.
You can read up on them in the dependencies section of the Gitlab docs. Some quotes to guide you:
Note that artifacts from all previous stages are passed by default.
So every artifact you build in a prior job of the same pipeline is passed by default.
(...) the artifacts from job:x will be downloaded and extracted in
the context of the build.
In the context of the build means relative to the working path of the job.
To test this, add a job after the one you create the artifact in and add a ls -la command in the next job to see what has been extracted and is ready for use.

How see all maven plugins available in repository?

I work with repository in local network without Internet access. I run build and fall with error because maven can not find a plugin. I can use other plugin but I am not sure that they stored in repository.
It is possible to run some maven command and see all plugins which available in local repository?
I don't think there is a local command to do this. But usually repositories have a web interface that allows you to browser or search.

how to build playorm JARs

I am new to playorm and gradle. My goal is to get playorm compiled (especially play 2.1 plugin) and deployed to local nexus repository manager.
What gradle tasks should I invoke to do this?
I tried to run gradlew clean assemble - creates workspace*.jar in output/libs so I assume build part was done. How to get these artefacts renamed and uploaded to my nexus?
https://github.com/deanhiller/playorm
You'll want to read this chapter of the user guide. It looks like the only repository configured for playorm is Maven Central, but the user guide tells you how to configure your own repository and interact with it. After following the guide, if you have a more specific question ask again here.
I created local.gradle and included it in build.gradle to create uploadArchives task using standard gradle upload procedure.
build.gradle was modified in upstream version to include local.gradle if exists.

Jenkins : how to check out artifact from Nexus and Deploy on Tomcat-

I am tying to set up a Jenkins Pipeline.
The first stage is done, the code compiles, is tested, inspected and deployed to Nexus.
I would like now to make a second stage on the pipeline where the war is checked out from Nexus and deployed on tomcat.
Actually I already integrated the maven-tomcat plugin to deploy on Tomcat.
My question is how can I check out the latest build of the war ?
Is there any maven or jenkins plugin for that ?
Many thanks,
Patrick
Your binary repository manager (Nexus) should ideally occupy the following position in you overall architecture:
You can use Jenkins as your provisioning tool, but ideally it should launch some sort of process which pulls the artifact to be deployed directly from Nexus (If nothing else it's more efficient).
This is a lot easier than it sounds. For example the Nexus REST API could be called from a shell script to download any desired revision of an artifact. For example:
$CATALINA_HOME/bin/shutdown.sh
curl -o $CATALINA_HOME/webapps/myfile.war http://myrepo.com/service/local/artifact/maven/redirect?r=releases&g=com.myorg&a=myfile&v=1.1.1&e=war
$CATALINA_HOME/bin/startup.sh
Finally, perhaps you might wish to consider a dedicated system for managing your deployments? An interesting solution I've been playing with is rundeck, which has a plugin for Jenkins. I really like rundeck, due to it's simplicity a trait it shares with Jenkins. There is also a plugin for Nexus that enables rundeck to provide a pull down list of artfacts eligible for deployment.
See download-artifact-from-nexus.sh script at https://github.com/cescoffier/puppet-nexus/tree/master/files
In my case, I modified it to use wget instead of curl. For some reason, curl wouldn't work for me.
I suggest you create a new pom for this. That way you are not bound to jenkins.
You need not explicitly checkout the artifact from nexus (note that this is called downloading from the repository in maven speech). You can specify a different war file location in the tomcat maven plugin. See the documentation. For downloading the latest version from the repository see the answers to this question.
i get the same problem with curl, i solved it buy adding the parameter -L, so that curl will follow the redirection to download the artifact, wget follows the redirection by default.
Below syntax has worked for me.
wget --user=admin --password=admin http://192.168.0.3:8081/repository/simpleapp-snapshot/in/javahome/simple-app/3.0.0-SNAPSHOT/simple-app-3.0.0-20210513.143540-1.war

Resources