I have the below code from where I am getting to the required file in Artifactory using the regex. But I want to printout the complete path at the later stage during the pipeline script execution. Can somebody tell me how do I access the complete path that Artifactory is getting the file from?
spec: """{
"files":
[
{
"pattern": "${ARTIFACTORY_PATH}/*/some_file.txt",
"target": "./",
"flat": "true",
"sortBy": ["created"],
"sortOrder": "desc",
"limit": 1
}
]}"""
I have a AQL that is used to delete files from the artifactory. I am designing a pipeline so that it can delete files from artifactory based on the AQL.
I know for artifactory upload and download we can specify the AQL within the pipeline using rtupload/rtdownload, but is there a way to do for delete as well?
#AQL delete.spec
{
"files": [
{
"aql": {
"items.find": {
"repo": {"$eq":"app-java-repo"},
"path": "archives/test/app",
"type": "folder",
"$or": [
{
"$and": [
{
"name": {"$nmatch" : "*build*"}
}
]
}
]
}
}
}
]
}
jf rt del --spec delete.spec
Using the jfrog cli, the spec file can be passed and the files from artifactory repo can be deleted. This is working out manually, but how can the same be achieved by having the AQL in the pipeline stage instead of having AQL as a file.
I am trying to integrate Bitbucket cloud with Jenkins. I have Bitbucket plugin installed in Jenkins. I have configured the webhook in bitbucket cloud for the repository with url http://<jenkins_url>/bitbucket-hook/
I set up Jenkins job (I tried both pipeline and multibranch pipeline). In the Pipeline I have selected "Build when a change is pushed to BitBucket" and In the pipeline I have stages to fetch from bitbucket and build. I have specified to get from branch develop.
case 1: After I set this up I pushed some code to my repository(branch develop). I expected the pipeline to be triggered(since I have a webhook setup) nothing happens.
I triggered the build manually. It builds the project. Now if I push something to the repository, the build is getting triggered. Question here is Why didn't it triggered the first time and works only after a manual build.
case 2: I setup another pipeline. Exactly as the one before. But with branch as master. I tried to follow the same step(triggered manually first). Now when i pushed something to master. Nothing happens(even after manual build).
When I analysed the jenkins log. I see that there is a notification from bitbucket cloud as soon as something is pushed. But the json which is sent doesn't has branch information. May be that is the reason Jenkins is not able to decide which pipeline to trigger when there are multiple pipelines talking to same repository. Is my assumption correct? Is it a bug in Bitbucket cloud
The json recieved from bitbucket cloud looks like this
{
"scm": "git",
"website": null,
"name": "myproject-api",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/my-team/myproject-api"
},
"html": {
"href": "https://bitbucket.org/my-team/myproject-api"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7Bb07e7384-c622-44b1-8c5f-96104d36cfae%7D?ts=java"
}
},
"project": {
"key": "PB",
"type": "project",
"uuid": "{d9c0caa2-7d43-4a0e-8459-2c7c8c2bd287}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/teams/my-team/projects/PB"
},
"html": {
"href": "https://bitbucket.org/account/user/my-team/projects/PB"
},
"avatar": {
"href": "https://bitbucket.org/account/user/my-team/projects/PB/avatar/32"
}
},
"name": "MyProject Backend"
},
"full_name": "my-team/myproject-api",
"owner": {
"username": "my-team",
"display_name": "my-team",
"type": "team",
"uuid": "{848f7612-ffbc-4dfb-8f67-ade4b604761c}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/teams/%7B848f7612-ffbc-4dfb-8f67-ade4b604761c%7D"
},
"html": {
"href": "https://bitbucket.org/%7B848f7612-ffbc-4dfb-8f67-ade4b604761c%7D/"
},
"avatar": {
"href": "https://bitbucket.org/account/my-team/avatar/"
}
}
},
"type": "repository",
"is_private": true,
"uuid": "{b07e7384-c622-44b1-8c5f-96104d36cfae}"
}
Does anyone have any idea how to successfully get webhooks working with bitbucket cloud and Jenkins. Most of the questions on SO regarding this talks about Bitbucket server and not Bitbucket cloud.
I had similar issues solved by doing following steps:
Uninstall old 'Bitbucket' plugin
Removed webhook at bitbucket that was set as:
http://<Jenkins URL>/bitbucket-hook/
Install 'Bitbucket Branch Source Plugin'
Set new webhook at bitbucket repository as:
http://<Jenkins URL>/bitbucket-scmsource-hook/notify/
Cheers!!!
I'm trying to integrate below's REST API call into Groovy and use Jenkin's Dynamic Parameter to list all the versions of the artifact. Please could you assist with the groovy script
The Artifactory version search REST API method can be used to get a list of all available artifact versions by GroupId and ArtifactId in local, remote or virtual repositories.
For example:
GET /api/search/versions?g=org.acme&a=artifact&repos=libs-release-local
{
"results": [
{
"version": "1.2",
"integration": false
},{
"version": "1.0-SNAPSHOT",
"integration": true
},{
"version": "1.0",
"integration": false
}
]
}
I have been following the below links in order to integrate Gitlab with Jenkins using web hooks. All the below links mention to receive 'JSON' or 'payload' or token over at Jenkins side, but I do not see anything when I try to echo or print these parameters in the Shell script of Jenkins configurations.
In shell script I have this, but I never receive any payloads:
echo "the build worked! The payload is $payload"
I do see some JSON coming through on /var/log/Jenkins/Jenkins.logs, but I want to see the messages coming in inside my 'Console Output', so that I can use the messages coming in from Gitlab to whether trigger a build or not.
Most of these links mention options are not available via Gitlab. One article was mentioning to convert web hook format to application/json, but there are no such options on the Gitlab UI.
How to process a github webhook payload in Jenkins?
http://chloky.com/github-json-payload-in-jenkins/
Jenkins Settings:
Gitlab webhook:
http://xx.xx.xx.xxx:8080/job/Interim_Build/buildWithParameters?token=TOKEN_NAME
Any help would be great. Thanks.
I suggest you to try two solutions (both working for me):
convert json data from Gitlab webhook using this elegant proxy written in Go https://github.com/akira/githookproxy .
It will take the webhook request, and translate it to a request to the target_url in the format of:
payload: JSON body
START: Start commit hash
END: End commit hash
REFNAME: Ref name
emulate jenkins as a Gitlab CI using this Jenkins plugin https://github.com/jenkinsci/gitlab-plugin
For me the best is the first because it is simple and more transparent.
GitLab and GitHub are two separate products. So, the documentation or links for GitHub webhooks that you are referring will not apply to GitLab webhooks.
GitLab invokes the webhook URL with a JSON payload in the request body that carries a lot of information about the GitLab event that led to the webhook invocation. For example, the GitLab webhook push event payload carries the following information in it:
{
"object_kind": "push",
"before": "95790bf891e76fee5e1747ab589903a6a1f80f22",
"after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"ref": "refs/heads/master",
"checkout_sha": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"user_id": 4,
"user_name": "John Smith",
"user_username": "jsmith",
"user_email": "john#example.com",
"user_avatar": "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80",
"project_id": 15,
"project":{
"id": 15,
"name":"Diaspora",
"description":"",
"web_url":"http://example.com/mike/diaspora",
"avatar_url":null,
"git_ssh_url":"git#example.com:mike/diaspora.git",
"git_http_url":"http://example.com/mike/diaspora.git",
"namespace":"Mike",
"visibility_level":0,
"path_with_namespace":"mike/diaspora",
"default_branch":"master",
"homepage":"http://example.com/mike/diaspora",
"url":"git#example.com:mike/diaspora.git",
"ssh_url":"git#example.com:mike/diaspora.git",
"http_url":"http://example.com/mike/diaspora.git"
},
"repository":{
"name": "Diaspora",
"url": "git#example.com:mike/diaspora.git",
"description": "",
"homepage": "http://example.com/mike/diaspora",
"git_http_url":"http://example.com/mike/diaspora.git",
"git_ssh_url":"git#example.com:mike/diaspora.git",
"visibility_level":0
},
"commits": [
{
"id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"message": "Update Catalan translation to e38cb41.",
"timestamp": "2011-12-12T14:27:31+02:00",
"url": "http://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327",
"author": {
"name": "Jordi Mallach",
"email": "jordi#softcatala.org"
},
"added": ["CHANGELOG"],
"modified": ["app/controller/application.rb"],
"removed": []
},
{
"id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"message": "fixed readme",
"timestamp": "2012-01-03T23:36:29+02:00",
"url": "http://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
"author": {
"name": "GitLab dev user",
"email": "gitlabdev#dv6700.(none)"
},
"added": ["CHANGELOG"],
"modified": ["app/controller/application.rb"],
"removed": []
}
],
"total_commits_count": 4
}
The Jenkins GitLab plugin makes this webhook payload information available in the Jenkins Global Variable env. The available env variables are as follows:
gitlabBranch
gitlabSourceBranch
gitlabActionType
gitlabUserName
gitlabUserEmail
gitlabSourceRepoHomepage
gitlabSourceRepoName
gitlabSourceNamespace
gitlabSourceRepoURL
gitlabSourceRepoSshUrl
gitlabSourceRepoHttpUrl
gitlabMergeRequestTitle
gitlabMergeRequestDescription
gitlabMergeRequestId
gitlabMergeRequestIid
gitlabMergeRequestState
gitlabMergedByUser
gitlabMergeRequestAssignee
gitlabMergeRequestLastCommit
gitlabMergeRequestTargetProjectId
gitlabTargetBranch
gitlabTargetRepoName
gitlabTargetNamespace
gitlabTargetRepoSshUrl
gitlabTargetRepoHttpUrl
gitlabBefore
gitlabAfter
gitlabTriggerPhrase
Just as you would read Jenkins job parameters from Jenkins Global Variable params in your job pipeline script, you could read webhook payload fields from Jenkins Global Variable env:
echo "My Jenkins job parameter is ${params.MY_PARAM_NAME}"
echo "One of Jenkins job webhook payload field is ${env.gitlabMergedByUser}"
Hope, the above information helps solve your problem.