doc/nwl-ci: added documentation about creating PR for src rev update
Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
parent
73baa394f1
commit
2a85c3ae25
|
|
@ -2148,6 +2148,208 @@ With this change we create a new version of the NWL docker instance:
|
|||
./manage.sh --image=nwl-env-ci:0.3.2 --branch=main --name=nwl_0_3_2 --platform=nwl --config=/home/user/work/ci/config/config.xml --revision=0.3.2 --maintainer=TeamCHBE create
|
||||
|
||||
|
||||
Commit and Pushing Changes
|
||||
**************************
|
||||
In general it is not possible to push directly to branch main. Thus, we need to go over a merge/pull request which we
|
||||
can achieve with a REST API call. I found a helpful REST API look-up page
|
||||
`here <https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-post>`_
|
||||
|
||||
From this page we get a template (cloud version) for our pull/merge request:
|
||||
|
||||
.. code-block::
|
||||
|
||||
curl --request POST \
|
||||
--url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests' \
|
||||
--header 'Authorization: Bearer <access_token>' \
|
||||
--header 'Accept: application/json' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"type": "<string>",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"html": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"commits": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"approve": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"diff": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"diffstat": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"comments": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"activity": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"merge": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
},
|
||||
"decline": {
|
||||
"href": "<string>",
|
||||
"name": "<string>"
|
||||
}
|
||||
},
|
||||
"id": 108,
|
||||
"title": "<string>",
|
||||
"rendered": {
|
||||
"title": {
|
||||
"raw": "<string>",
|
||||
"markup": "markdown",
|
||||
"html": "<string>"
|
||||
},
|
||||
"description": {
|
||||
"raw": "<string>",
|
||||
"markup": "markdown",
|
||||
"html": "<string>"
|
||||
},
|
||||
"reason": {
|
||||
"raw": "<string>",
|
||||
"markup": "markdown",
|
||||
"html": "<string>"
|
||||
}
|
||||
},
|
||||
"summary": {
|
||||
"raw": "<string>",
|
||||
"markup": "markdown",
|
||||
"html": "<string>"
|
||||
},
|
||||
"state": "OPEN",
|
||||
"author": {
|
||||
"type": "<string>"
|
||||
},
|
||||
"source": {
|
||||
"repository": {
|
||||
"type": "<string>"
|
||||
},
|
||||
"branch": {
|
||||
"name": "<string>",
|
||||
"merge_strategies": [
|
||||
"merge_commit"
|
||||
],
|
||||
"default_merge_strategy": "<string>"
|
||||
},
|
||||
"commit": {
|
||||
"hash": "<string>"
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"repository": {
|
||||
"type": "<string>"
|
||||
},
|
||||
"branch": {
|
||||
"name": "<string>",
|
||||
"merge_strategies": [
|
||||
"merge_commit"
|
||||
],
|
||||
"default_merge_strategy": "<string>"
|
||||
},
|
||||
"commit": {
|
||||
"hash": "<string>"
|
||||
}
|
||||
},
|
||||
"merge_commit": {
|
||||
"hash": "<string>"
|
||||
},
|
||||
"comment_count": 51,
|
||||
"task_count": 53,
|
||||
"close_source_branch": true,
|
||||
"closed_by": {
|
||||
"type": "<string>"
|
||||
},
|
||||
"reason": "<string>",
|
||||
"created_on": "<string>",
|
||||
"updated_on": "<string>",
|
||||
"reviewers": [
|
||||
{
|
||||
"type": "<string>"
|
||||
}
|
||||
],
|
||||
"participants": [
|
||||
{
|
||||
"type": "<string>"
|
||||
}
|
||||
]
|
||||
}'
|
||||
|
||||
.. note::
|
||||
Currently we do not have a specific NetModule CI user (located in the AD) as we have had for the OEM Linux CI and
|
||||
in addition we do not want to add username and password in a REST API call. So, we will create a project specific
|
||||
HTTP access token. This would limit the access to only this repository and not to all of the repositories that a
|
||||
user would have. See next sections about how the PR is finally set up.
|
||||
|
||||
|
||||
Create HTTP Access Token
|
||||
========================
|
||||
The following steps guide you through the setup of a HTTP access token.
|
||||
|
||||
#. Browse on Bitbucket to the repository `Netmodule Wireless Linux <https://bitbucket.gad.local/projects/NM-NSP/repos/netmodule-wireless-linux/browse>`_
|
||||
#. Within the *repository settings* select *HTTP access tokens*
|
||||
#. Create a token:
|
||||
|
||||
#) Press *Create token*
|
||||
#) Enter a name for the token, e.g. *CI user*
|
||||
#) Select *write* for the repository permissions
|
||||
#) OPTIONAL: Set an expiration time in days
|
||||
#) Press *Create*
|
||||
#) IMPORTANT: Store the generated token to a secure place like KeePass database or similar
|
||||
|
||||
#. The generated token will be used for the REST API call, see next section
|
||||
|
||||
|
||||
Create Merge/Pull Request over REST API
|
||||
=======================================
|
||||
Once we have pushed our changes to the branch *nightly* we can create a pull request using the HTTP access token from
|
||||
the section before:
|
||||
|
||||
.. code-block::
|
||||
|
||||
curl --request POST \
|
||||
--url 'https://bitbucket.gad.local/rest/api/1.0/projects/NM-NSP/repos/netmodule-wireless-linux/pull-requests' \
|
||||
--header 'Authorization: Bearer <ACCESS_TOKEN>' \
|
||||
--header 'Accept: application/json' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '<PR_DATA_JSON>'
|
||||
|
||||
# where
|
||||
# - <ACCESS_TOKEN>: the access token you stored at creation time in section `Create HTTP Access Token`
|
||||
# - <PR_DATA_JSON>:
|
||||
# { "title": "Nightly: Src Rev Update", \
|
||||
# "description": "CI is ppdating the source revisions to HEAD", \
|
||||
# "state": "OPEN", "open": true, "closed": false, \
|
||||
# "fromRef": { "id": "refs/heads/nightly", \
|
||||
# "repository": {"slug": "netmodule-wireless-linux", "name": null, "project": {"key": "NM-NSP"}} \
|
||||
# }, \
|
||||
# "toRef": { "id": "refs/heads/main", \
|
||||
# "repository": {"slug": "netmodule-wireless-linux", "name": null, "project": {"key": "NM-NSP"}} \
|
||||
# }, \
|
||||
# "locked": false,\
|
||||
# "reviewers": [{"user": {"name": "bard"}}], "links": {"self": [null]} \
|
||||
# }
|
||||
|
||||
.. note::
|
||||
* The REST API URL version is different to the template we have seen before. I did not find an example for data
|
||||
center version with 2.0, thus I don't know if 2.0 is working
|
||||
* Alexandre Bard (bard) is set as default reviewer
|
||||
|
||||
|
||||
Nightly Trigger Integration
|
||||
###########################
|
||||
With the Job DSL plugin version 1.77 the option ``triggers`` is deprecated and will be removed soon (reason: it caused
|
||||
|
|
|
|||
Loading…
Reference in New Issue