Perform Maven Release with dry-run checkbox from jenkins - maven

Need to Trigger "Perform Maven Release" of other job by using command smthing like this
curl 'https://192.10.160.105/jenkins/view/job/mavwn/m2release/'
-H 'Content-Type: application/x-www-form-urlencoded'
--data 'releaseVersion=$releaseVersion&developmentVersion=$developmentVersion&json={ releaseVersion: $releaseVersion, developmentVersion: $developmentVersion}&Submit=Schedule+Maven+Release+Build'
mentioned in
"https://medium.com/#fercalderon/how-to-trigger-a-maven-release-job-from-a-pipeline-job-in-jenkins-6449cf2e6263"
But in the maven Jenkins job there is dry-run checkbox to select, How to select dry-box through given command and schedule a build? Please share if any one has any idea?. Thanks in advance

you can do like this to select a checkbox when triggering the build
&name=dry-box&value=on
curl 'https://192.10.160.105/jenkins/view/job/mavwn/m2release/'
-H 'Content-Type: application/x-www-form-urlencoded'
--data 'releaseVersion=$releaseVersion&developmentVersion=$developmentVersion&name=dry-box&value=on&json={ releaseVersion: $releaseVersion, developmentVersion: $developmentVersion}&Submit=Schedule+Maven+Release+Build'

Related

Bitbucket Tagging for every bitbucket commit

Need help for creating tag for every bit bucket commit.
Please let me know if anyone have implemented this using Jenkins pipeline, if yes how can we achieve that
I'm going to assume you have some sort of Multi-branch pipeline job set up, or some mechanism to trigger a jenkins job for each commit to BitBucket. Bitbucket will need to trigger a Jenkins job for each commit via a webhook
In your pipeline code, you'll need to do the following:
Get the hash of your commit. You can get this data from the GIT_COMMIT variable in the Git Jenkins Plugin
Create a Bitbucket tag via their api with the commit hash mentioned above
curl https://api.bitbucket.org/2.0/repositories/jdoe/myrepo/refs/tags \
-s -u jdoe -X POST -H "Content-Type: application/json" \
-d '{
"name" : "new-tag-name",
"target" : {
"hash" : "a1b2c3d4e5f6",
}
}'
There are few different ways to do #2.
Put that code in a powershell script and run it from your job.
Call it directly from your jenkins pipeline like this stackoverflow answer.
Or if you plan to do this from many jobs, you could also create your own Bitbucket Api Client shared library that does the api interaction for you.
Note: You'll likely need to authenticate these Bitbucket api requests
I was able to get rid of error using env.GIT_COMMIT

Toggle heroku maintenance mode without CLI or Web UI

I'm using Jenkins to run tests before deploying to Heroku using a git publisher plugin. I want to sandwich my deploy with maintenance mode ON/OFF but don't want to install the heroku toolbelt (reference) on my jenkins machine (nor do I want to go to the Web UI and toggle the maintenance mode manually). I don't want to install the heroku toolbelt on jenkins because it adds to the customization and configuration I'd need to do to the jenkins installation and I want to keep my jenkins instance as disposable as possible...driven rather by source code pipelines (Jenkinsfile).
Ideas:
utilize a docker image that has the heroku toolbelt installed on it
utilize a multi-buildpack that does it for me?
Any suggestions or experience on how I might accomplish this?
You can use heroku's platform api to do this:
https://devcenter.heroku.com/articles/platform-api-reference#app-update
The following curl request will put your app into maintenance mode:
curl -n -X PATCH https://api.heroku.com/apps/$APP_ID_OR_NAME \
-d '{"maintenance": true}' \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3"
-H "Authorization: Bearer <heroku token>
You will just need to replace the app name, as well as the token.
You can generate OAuth tokens using the cli-oauth cli plugin locally.

Can I trigger Team City build from Windows Command Line?

I have setup a Teamcity Project in Windows system within Teamcity.
But I wish to trigger the Teamcity build from Windows command prompt.
Is this possible?
If yes, Is there any documentation or setup guide for this?
Taken from the TeamCity documentation:
curl -v -u user:password http://teamcity.server.url:8111/app/rest/buildQueue --request POST --header "Content-Type:application/xml" --data-binary #build.xml
https://confluence.jetbrains.com/display/TCD9/REST+API#RESTAPI-TriggeringaBuild

Setting namespace of a GitLab repository

This is my Ruby script for GitLab API, I'm doing commits and pushes with it: https://github.com/ivanove/my_works/blob/master/Create-Repo.rb
I'm using CURL inside of it to make requests.
So the question is, how can I set namespace of repository when it's created?
This is the command I use:
cmd = %Q<curl -H "Content-Type:application/json" http://#{#host}/api/v3/projects?private_token=#{#token} -d '{"name":"#{name}","visibility_level":20,"namespace_id":"group-from-1"}'>
I added namespace_id from GitLab Documentation, but it doesn't work.

Upgrading to cedar-14 when deploying via the heroku API

To migrate from cedar to cedar-14 the docs says to first to a heroku stack:set cedar-14 and then the app will be migrated on the next git push.
The problem is that we are not using buildpacks but instead build our own slug which we publish through the heroku API.
Is there a way to trigger the migration without pushing to the heroku git repo?
To change the stack using the build API you need to send the stack as part of the Slug create post call.
e.g
local response=`curl -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.heroku+json; version=3' \
-d { \
"process_types": { \
"web": "java $JAVA_OPTS -Djetty.port=$PORT -jar target/dependency/jetty-runner.jar --config jetty.xml target/xxxx.war" \
}, \
"stack": "cedar-14" \
} \
-n https://api.heroku.com/apps/EXAMPLE_APP/slugs`
This will change your stack!
NOTE: You need to include the correct JVM when creating the slug

Resources