About Python pip install and versioning

Backgroup

If you want to release python project on PyPI, you must need to know about PyPI usage characteristics, then I did some test about pip install command.

For example: I have a Python project called demo-pip. and beta release would like 1.1.0.xxxx, offical release version is 1.1.0 to see if could success upgrade when using pip command.

Base on the below test results, I summarized as follows:

  1. Install a specific version of demo-pip from PyPI, with --upgrade option or not, they’ll all both success.
  2. Install the latest package version of demo-pip from PyPI that version is large than the locally installed package version, with --upgrade option installs successfully. without --upgrade option install failed.
  3. Install the latest package version of demo-pip from PyPI that version is less than the locally installed package version, with --upgrade option or not, install failed.
  4. 1.1.0.xxxx version naming is OK, but when the beta version is larger than 1.1.0, for example, the beta version is 1.1.0.1000, pip install with --upgrade not work when our official release version is 1.1.0.
    a. One option is the official release version start from 1.1.0.1000, beta version starts from 1.1.0.0001, 1.1.0.0002… Or the beta version should be less than 1.1.0, maybe 1.0.0.xxxx
    b. Another option is follow up python official versioning that is the best practice, then the beta release version will be 1.1.b1, 1.1.b2, 1.1.bN… (it passed No.5 test below)

My Test Case

Read More

Update Jira server account avatar with rest API

Backgroud

When you are using a server account for CI/CD, if you want to make the server account avatar to looks professional on Jira update but the server account may not allowed to log to Jira, so you can not update the avatar though GUI, you could use Jira REST API to do this.

I assume you have an account called robot, here are the examples of how to update though REST API.

Example in Python

import http.client

conn = http.client.HTTPSConnection("jira.your-company.com")

payload = "{\r\n\t\"id\": \"24880\",\r\n\t\"isSelected\": false,\r\n\t\"isSystemAvatar\": true,\r\n\t\"urls\": {\r\n\t\t\"16x16\": \"https://jira.your-company.com/secure/useravatar?size=xsmall&avatarId=24880\",\r\n\t\t\"24x24\": \"https://jira.your-company.com/secure/useravatar?size=small&avatarId=24880\",\r\n\t\t\"32x32\": \"https://jira.your-company.com/secure/useravatar?size=medium&avatarId=24880\",\r\n\t\t\"48x48\": \"https://jira.your-company.com/secure/useravatar?avatarId=24880\"}\r\n}"

headers = {
'content-type': "application/json",
'authorization': "Basic Ymx3bXY6SzhNcnk5ZGI=",
'cache-control': "no-cache",
'postman-token': "ecfc3260-9c9f-e80c-e3e8-d413f48dfbf4"
}

conn.request("PUT", "/rest/api/latest/user/avatar?username=robot", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Example in Postman

Read More

Fixed "Remote session was disconnected because there are no Remote Desktop client access licenses available"

Problem

Sometimes my Windows server 2012 R2 has RDP connect problem below:

The remote session was disconnected because there are no Remote Desktop client access licenses available for this computer.
Please contact the server administrator.

RDP connect problem

Read More

通过 generic-webhook-trigger 插件实时获取 Bitbucket Repository Events

背景

本篇讨论如何通过 Jenkins generic webhook trigger 插件来获取 Git 仓库事件(Events)。比如获取仓库的 Pull Request ID 等。

使用过 Jenkins Multi-branch pipeline Job 的用户知道,这个 Job 类型的环境变量中可以得到 Pull Request 的相关信息如下

Multi-branch pipeline Job 环境变量

为了获取这个变量需要创建这种类型的 Job,并且可能需要 clone 该仓库的代码,有点杀鸡宰牛的意思,看起来并不是一个特别恰当的办法。

如何通过创建一个普通的 Jenkins Job 就能实时获取 Bitbucket 仓库以及 Pull Request 事件呢?通过以下功能和插件可以实现。

Read More

Annual work summary from 2019.03 - 2020.07

Summarize what did I do from 2019.03 to 2020.07 when I became a Build Release/DevOps engineer.

Build automation

  • Support all server windows platform build manual to auto.
  • Support clients build from manual to auto.
  • Switch Linux/Unix build from Bamboo to Jenkins.
  • Support all platforms branches/Pull Request build.
  • Provide auto-build as self-service for a developer, no need to involve build engineer, they could build themselves.

Integration

  • Integration with Jenkins

    • Self-service installation.
    • Blackduck, Polaris integration.
    • Git stats, analyze Bitbucket data with Elastic stack.
    • Monitor legacy build machines status.
    • Product escrow, sync xdemo, provide NFS and SYNC mvopensrc, update Bitbucket Jenkins build status, etc.
  • Integration with JFrog Ariifactory

    • Establish deploy strategy and directory structure organization.
    • Handle artifacts(build, etc) with different maturity.

Infrastructure management

  • Manage Jenkins for setting, update and backup.
  • Ariifactory artifacts cleanup, retention, backup.
  • Git branches/hooks management.
  • VMs tracking, management build machines.

Jenkins 执行 Shell 如果返回值不为0,作业(Job)停止并失败怎么办?

《Jenkins Tips 3》—— 每期用简短的图文描述一个 Jenkins 小技巧。

问题

在使用 Jenkins pipeline 时,如果 Shell 的返回值不为零(也就是 Shell 命令执行时有错误),Jenkins Job 默认会标记当前的 stage 为失败。因此整个 Job 也会失败。

在有些时候我们希望 Shell 虽然执行失败返回的不为零,但希望Jenkins Job 在执行成功后,要显示成功状态。

Read More

How to fix ".NET Framework 2.0 or later is required on this computer to run a Jenkins agent as a Windows service"

When I upgrade Jenkins 2.176.3 to Jenkins 2.235.1, my Windows agent can not connect with master successfully and outcome this warning message “.NET Framework 2.0 or later is required on this computer to run a Jenkins agent as a Windows service”.

Read More

每个 Jenkins 用户都应该知道这三个最佳实践

​在使用 Jenkins 实施了企业级的 CI/CD 工作,有如下三个最重要的实践和总结。

第一,Configuration as Code(配置即代码)
其次,Jenkins shared libraries(Jenkins 共享库)
最后,Multi-Branch Pipeline(多分支流水线)

配置即代码

配置即代码(Configuration as Code)是一种在代码仓库里管理配置的方法。

它有什么好处

作业透明化

Read More

Jenkins Top 3 best practice

I am Xianpeng, a build engineer. Today, I am going to share with you three Jenkins Practice.

I will talk about Configuration as code, followed up with shared libraries, and then Multi-Branch Pipeline in the end.

Configuration as Code

What is Configuration as Code?

Configuration as code (CAC) is an approach that managing configuration resources in a bitbucket repository

What are the benefits?

First, Jenkins Job Transparency

Read More

将 Jenkins Shell 返回的字符串处理为字符数组

《Jenkins Tips 2》 —— 每期用简短的图文描述一个 Jenkins 小技巧。

问题

想要把 Linux 上不同的文本数据通过 Jenkins 发送邮件给不同的人。

Read More