html tool

显示标签为“gitlab,”的博文。显示所有博文
显示标签为“gitlab,”的博文。显示所有博文

2019年5月29日星期三

gitlab的yml中的job条件


问题:


  1. gitlab的yml中job的执行条件如何定义?
  2. 可以有没有stage的job吗?

结果:

  1.  gitlab的yml中job的执行条件如何定义?


only and except
only和except两个参数说明了job什么时候将会被创建:
  1. only定义了job需要执行的所在分支或者标签
  2. except定义了job不会执行的所在分支或者标签 [note:检索 popexizhi]
以下是这两个参数的几条用法规则:
  1. only和except如果都存在在一个job声明中,则所需引用将会被only和except所定义的分支过滤.
  2. only和except允许使用正则
  3. only和except允许使用指定仓库地址,但是不forks仓库
例子解析:
  1. job将会只在issue-开头的refs下执行,反之则其他所有分支被跳过:
    job:
        # use regexp
        only:
            - /^issue-.*$/ #[popexizhi: 这里对commit 的message直接过滤,看来是很可以有获得commit的file方式的]
        # use special keyword
        except:
            - branches
    
  2. job只会在打了tag的分支,或者被api所触发,或者每日构建任务上运行,
    job:
        # use special keywords
        only:
            - tags      # tag 分支 commit 之后触发
            - triggers  # API 触发 [note:检索 popexizhi]
            - schedules # 每日构建触发 [note:检索 popexizhi]
  3. job将会在父仓库gitlab-org/gitlab-ce的非master分支有提交时运行。
    job:
        only:
            - branches@gitlab-org/gitlab-ce [note:检索 popexizhi]
        except:
            - master@gitlab-org/gitlab-ce [note:检索 popexizhi]
参考:
https://www.jianshu.com/p/3c0cbb6c2936

2.可以有没有stage的job吗?

当前测试结果是不可以,如果使用如下方式:

  1 stages:
  2   - deploy
  3   - test
  4 # - reporting
  5 #生成测试报告-jenkins test
  6 executing-test:
  7   stage: reporting
  8   only:
  9     - /^-all reporting.*$/
 10     # use special keyword
 11   except:
 12     - branches
 13   script:
 15   - bash start_detect_test 12221 test174
 16 #运行commit的单元测试
 17 unittest:
 18   stage: test
 19   script:
 20     # get commit dir,running dir python *_test.py
 21     "bash test_for_unittest.sh"
~                                      

push 到gitlab提示fail格式如下:


2019年1月10日星期四

gitlab project的ci设置

测试了半日,其实添加项目后直接在如下位置设置Enable for this project ,push
后就都ok了,好吧mark一下


PS:
新添加的ci runner 没有勾选untagged 也会影响,run,没有定义tag的.gitlab-ci.yml


2017年5月9日星期二

gitlab中使用无密码push

问题:
在gitlab的project deploy key 中“+ New Deploy Key”key
在本地push时总是提示"
GitLab: Deploy keys are not allowed to push code.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists
"

仔细查了一下,gitlab的deploy key和 在user的

SSH Keys 中绑定的key的区别


参考:
https://docs.gitlab.com/ce/ssh/README.html#applications

Deploy keys 

Deploy keys allow read-only or read-write (if enabled) 『popexizhi: 应该一定是enabled 来的key 』access to one or multiple projects with a single SSH key pair.
This is really useful for cloning repositories to your Continuous Integration (CI) server. By using deploy keys, you don't have to setup a dummy user account.
If you are a project master or owner, you can add a deploy key in the project settings under the section 'Repository'. Specify a title for the new deploy key and paste a public SSH key. After this, the machine that uses the corresponding private SSH key has read-only or read-write (if enabled) access to the project.
You can't add the same deploy key twice using the form. If you want to add the same key to another project, please enable it in the list that says 'Deploy keys from projects available to you'. All the deploy keys of all the projects you have access to are available. This project access can happen through being a direct member of the project, or through a group.
Deploy keys can be shared between projects, you just need to add them to each project.
-------------------------------------------------------------------
在同样的问题下给的回复:"SSH - GitLab: Deploy keys are not allowed to push code. fatal: Could not read from remote repository"
https://gitlab.com/gitlab-org/gitlab-ce/issues/5910
Deploy keys only have read-only access to the repo. If you wish to push, you need to add an SSH key to your user and make sure git is using that key, not the deploy key.
-------------------------------------------------------------------
[next]
另外有人回复
Deploy keys are now allowed to push, too, if you specifically allow this behavior. See #1376 (closed). Also the API docs on deploy keys mention that feature.
(Unfortunately, the can_push value doesn't seem to be transmitted correctly through the API; keys that I create through with API calls are all read-only. Anyone else experiencing the same issue?)
没有尝试,next试试去 https://gitlab.com/gitlab-org/gitlab-ce/issues/1376