diff --git a/doc/src/setup/nwl-ci.rst b/doc/src/setup/nwl-ci.rst index 344dfe7..adc8936 100644 --- a/doc/src/setup/nwl-ci.rst +++ b/doc/src/setup/nwl-ci.rst @@ -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 `_ + +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 ' \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json' \ + --data '{ + "type": "", + "links": { + "self": { + "href": "", + "name": "" + }, + "html": { + "href": "", + "name": "" + }, + "commits": { + "href": "", + "name": "" + }, + "approve": { + "href": "", + "name": "" + }, + "diff": { + "href": "", + "name": "" + }, + "diffstat": { + "href": "", + "name": "" + }, + "comments": { + "href": "", + "name": "" + }, + "activity": { + "href": "", + "name": "" + }, + "merge": { + "href": "", + "name": "" + }, + "decline": { + "href": "", + "name": "" + } + }, + "id": 108, + "title": "", + "rendered": { + "title": { + "raw": "", + "markup": "markdown", + "html": "" + }, + "description": { + "raw": "", + "markup": "markdown", + "html": "" + }, + "reason": { + "raw": "", + "markup": "markdown", + "html": "" + } + }, + "summary": { + "raw": "", + "markup": "markdown", + "html": "" + }, + "state": "OPEN", + "author": { + "type": "" + }, + "source": { + "repository": { + "type": "" + }, + "branch": { + "name": "", + "merge_strategies": [ + "merge_commit" + ], + "default_merge_strategy": "" + }, + "commit": { + "hash": "" + } + }, + "destination": { + "repository": { + "type": "" + }, + "branch": { + "name": "", + "merge_strategies": [ + "merge_commit" + ], + "default_merge_strategy": "" + }, + "commit": { + "hash": "" + } + }, + "merge_commit": { + "hash": "" + }, + "comment_count": 51, + "task_count": 53, + "close_source_branch": true, + "closed_by": { + "type": "" + }, + "reason": "", + "created_on": "", + "updated_on": "", + "reviewers": [ + { + "type": "" + } + ], + "participants": [ + { + "type": "" + } + ] + }' + +.. 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 `_ +#. 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 ' \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json' \ + --data '' + + # where + # - : the access token you stored at creation time in section `Create HTTP Access Token` + # - : + # { "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