diff --git a/AUTHORS b/AUTHORS index 6beee8bf55..52009d3146 100644 --- a/AUTHORS +++ b/AUTHORS @@ -841,6 +841,7 @@ Developers: sachingarg05 Re-added orientation change callback in java activity + GLProgram should not abort() if shader compilation fails, returning false is better. dplusic Fixed that cc.pGetAngle may return wrong value @@ -881,6 +882,12 @@ Developers: zhouxiaoxiaoxujian Added TextField::getStringLength() Add shadow, outline, glow filter support for UIText + + QiuleiWang + Fix the bug that calculated height of multi-line string was incorrect on iOS + + Rumist + Fix the bug that the result of Director->convertToUI() is error. Retired Core Developers: WenSheng Yang diff --git a/CHANGELOG b/CHANGELOG index 9b745809d9..4d58d944e0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,11 +11,15 @@ cocos2d-x-3.2 ??? [FIX] Android: 3d model will be black when coming from background [FIX] Android: don't trigger EVENT_COME_TO_BACKGROUND event when go to background [FIX] Cocos2dxGLSurfaceView.java: prevent flickering when opening another activity + [FIX] Director: Director->convertToUI() returns wrong value. + [FIX] GLProgram: not abort if shader compilation fails, just retuan false. [FIX] GLProgramState: sampler can not be changed [FIX] Image: Set jpeg save quality to 90 [FIX] Image: premultiply alpha when loading png file to resolve black border issue [FIX] Label: label is unsharp if it's created by smaller font [FIX] Label: Label's display may go bonkers if invoking Label::setString() with outline feature enabled + [FIX] Label: don't release cached texture in time + [FIX] Label: calculated height of multi-line string was incorrect on iOS [FIX] Lua-binding: compiling error on release mode [FIX] Lua-binding: Add xxtea encrypt support [FIX] Node: setPhysicsBody() can not work correctly if it is added to a Node @@ -25,8 +29,10 @@ cocos2d-x-3.2 ??? [FIX] Repeat: will run one more over in rare situations [FIX] Scale9Sprite: support culling [FIX] Schedule: schedulePerFrame() can not be called twice + [FIX] ShaderTest: 7 times performance improved of blur effect [FIX] SpriteFrameCache: fix memory leak [FIX] Texture2D: use image's pixel format to create texture + [FIX] TextureCache: addImageAsync() may repeatedly generate Image for the same image file [FIX] WP8: will restart if app goes to background, then touches icon to go to foreground [FIX] WP8: will be black if: 1. 3rd pops up a view; 2. go to background; 3. come to foreground [FIX] WP8: project name of new project created by console is wrong diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 39ef02f014..d01925bbd0 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -392,16 +392,12 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false * if (_reusedLetter == nullptr) { - _reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0)); + _reusedLetter = Sprite::create(); _reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB); _reusedLetter->retain(); _reusedLetter->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); - _reusedLetter->setBatchNode(this); - } - else - { - _reusedLetter->setTexture(_fontAtlas->getTexture(0)); } + _reusedLetter->setBatchNode(this); if (_fontAtlas) { diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index af64540683..37a477357f 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -280,6 +280,7 @@ + @@ -476,6 +477,7 @@ + diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index e7f75c3fd6..010792145b 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -593,6 +593,9 @@ renderer + + base + @@ -1205,6 +1208,9 @@ renderer + + base + diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 9d1e02f187..ac7519a062 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2011 Zynga Inc. @@ -763,6 +763,18 @@ Vec2 Director::convertToUI(const Vec2& glPoint) Vec4 glCoord(glPoint.x, glPoint.y, 0.0, 1); transform.transformVector(glCoord, &clipCoord); + /* + BUG-FIX #5506 + + a = (Vx, Vy, Vz, 1) + b = (a×M)T + Out = 1 ⁄ bw(bx, by, bz) + */ + + clipCoord.x = clipCoord.x / clipCoord.w; + clipCoord.y = clipCoord.y / clipCoord.w; + clipCoord.z = clipCoord.z / clipCoord.w; + Size glSize = _openGLView->getDesignResolutionSize(); float factor = 1.0/glCoord.w; return Vec2(glSize.width*(clipCoord.x*0.5 + 0.5) * factor, glSize.height*(-clipCoord.y*0.5 + 0.5) * factor); diff --git a/cocos/platform/ios/CCDevice.mm b/cocos/platform/ios/CCDevice.mm index 5eeaf7ccaa..fb14b01f71 100644 --- a/cocos/platform/ios/CCDevice.mm +++ b/cocos/platform/ios/CCDevice.mm @@ -215,26 +215,14 @@ static inline void lazyCheckIOS7() static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize) { - NSArray *listItems = [str componentsSeparatedByString: @"\n"]; - CGSize dim = CGSizeZero; CGSize textRect = CGSizeZero; textRect.width = constrainSize->width > 0 ? constrainSize->width : 0x7fffffff; textRect.height = constrainSize->height > 0 ? constrainSize->height : 0x7fffffff; - for (NSString *s in listItems) - { - CGSize tmp = [s sizeWithFont:font constrainedToSize:textRect]; - - if (tmp.width > dim.width) - { - dim.width = tmp.width; - } - - dim.height += tmp.height; - } - + CGSize dim = [str sizeWithFont:font constrainedToSize:textRect]; + dim.width = ceilf(dim.width); dim.height = ceilf(dim.height); diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index da2f4cf503..d5b492e941 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -140,9 +140,17 @@ GLProgram::~GLProgram() { CCLOGINFO("%s %d deallocing GLProgram: %p", __FUNCTION__, __LINE__, this); - // there is no need to delete the shaders. They should have been already deleted. - CCASSERT(_vertShader == 0, "Vertex Shaders should have been already deleted"); - CCASSERT(_fragShader == 0, "Fragment Shaders should have been already deleted"); + if (_vertShader) + { + glDeleteShader(_vertShader); + } + + if (_fragShader) + { + glDeleteShader(_fragShader); + } + + _vertShader = _fragShader = 0; if (_program) { @@ -444,7 +452,7 @@ bool GLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source } free(src); - abort(); + return false;; } return (status == GL_TRUE); } diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index 16643adeb9..d7db2feaa8 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -206,11 +206,11 @@ void TextureCache::loadImage() for (; pos < infoSize; pos++) { imageInfo = (*_imageInfoQueue)[pos]; - if(imageInfo->asyncStruct->filename.compare(asyncStruct->filename)) + if(imageInfo->asyncStruct->filename.compare(asyncStruct->filename) == 0) break; } _imageInfoMutex.unlock(); - if(infoSize == 0 || pos < infoSize) + if(infoSize == 0 || pos == infoSize) generateImage = true; } diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 9aa84d87e0..b4150a8383 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -421,22 +421,16 @@ class SpriteBlur : public Sprite { public: ~SpriteBlur(); - void setBlurSize(float f); bool initWithTexture(Texture2D* texture, const Rect& rect); void initGLProgram(); static SpriteBlur* create(const char *pszFileName); + void setBlurRadius(float radius); + void setBlurSampleNum(float num); protected: - - int _blurRadius; - Vec2 _pixelSize; - - int _samplingRadius; - //gaussian = cons * exp( (dx*dx + dy*dy) * scale); - float _scale; - float _cons; - float _weightSum; + float _blurRadius; + float _blurSampleNum; }; SpriteBlur::~SpriteBlur() @@ -472,14 +466,7 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); #endif - auto s = getTexture()->getContentSizeInPixels(); - - _pixelSize = Vec2(1/s.width, 1/s.height); - - _samplingRadius = 0; - this->initGLProgram(); - - getGLProgramState()->setUniformVec2("onePixelSize", _pixelSize); + initGLProgram(); return true; } @@ -495,43 +482,23 @@ void SpriteBlur::initGLProgram() auto glProgramState = GLProgramState::getOrCreateWithGLProgram(program); setGLProgramState(glProgramState); + + auto size = getTexture()->getContentSizeInPixels(); + getGLProgramState()->setUniformVec2("resolution", size); + getGLProgramState()->setUniformFloat("blurRadius", _blurRadius); + getGLProgramState()->setUniformFloat("sampleNum", 7.0f); } -void SpriteBlur::setBlurSize(float f) +void SpriteBlur::setBlurRadius(float radius) { - if(_blurRadius == (int)f) - return; - _blurRadius = (int)f; + _blurRadius = radius; + getGLProgramState()->setUniformFloat("blurRadius", _blurRadius); +} - _samplingRadius = _blurRadius; - if (_samplingRadius > 10) - { - _samplingRadius = 10; - } - if (_blurRadius > 0) - { - float sigma = _blurRadius / 2.0f; - _scale = -0.5f / (sigma * sigma); - _cons = -1.0f * _scale / 3.141592f; - _weightSum = -_cons; - - float weight; - int squareX; - for(int dx = 0; dx <= _samplingRadius; ++dx) - { - squareX = dx * dx; - weight = _cons * exp(squareX * _scale); - _weightSum += 2.0 * weight; - for (int dy = 1; dy <= _samplingRadius; ++dy) - { - weight = _cons * exp((squareX + dy * dy) * _scale); - _weightSum += 4.0 * weight; - } - } - } - log("_blurRadius:%d",_blurRadius); - - getGLProgramState()->setUniformVec4("gaussianCoefficient", Vec4(_samplingRadius, _scale, _cons, _weightSum)); +void SpriteBlur::setBlurSampleNum(float num) +{ + _blurSampleNum = num; + getGLProgramState()->setUniformFloat("sampleNum", _blurSampleNum); } // ShaderBlur @@ -551,22 +518,43 @@ std::string ShaderBlur::subtitle() const return "Gaussian blur"; } -ControlSlider* ShaderBlur::createSliderCtl() +void ShaderBlur::createSliderCtls() { auto screenSize = Director::getInstance()->getWinSize(); - ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); - slider->setAnchorPoint(Vec2(0.5f, 1.0f)); - slider->setMinimumValue(0.0f); // Sets the min value of range - slider->setMaximumValue(25.0f); // Sets the max value of range + { + ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); + slider->setAnchorPoint(Vec2(0.5f, 1.0f)); + slider->setMinimumValue(0.0f); + slider->setMaximumValue(25.0f); + slider->setScale(0.6f); + slider->setPosition(Vec2(screenSize.width / 4.0f, screenSize.height / 3.0f)); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::onRadiusChanged), Control::EventType::VALUE_CHANGED); + slider->setValue(2.0f); + addChild(slider); + _sliderRadiusCtl = slider; + + auto label = Label::createWithTTF("Blur Radius", "fonts/arial.ttf", 12.0f); + addChild(label); + label->setPosition(Vec2(screenSize.width / 4.0f, screenSize.height / 3.0f - 24.0f)); + } - slider->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 3.0f)); - - // When the value of the slider will change, the given selector will be call - slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), Control::EventType::VALUE_CHANGED); - slider->setValue(2.0f); - - return slider; + { + ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); + slider->setAnchorPoint(Vec2(0.5f, 1.0f)); + slider->setMinimumValue(0.0f); + slider->setMaximumValue(11.0f); + slider->setScale(0.6f); + slider->setPosition(Vec2(screenSize.width * 3 / 4.0f, screenSize.height / 3.0f)); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::onSampleNumChanged), Control::EventType::VALUE_CHANGED); + slider->setValue(7.0f); + addChild(slider); + _sliderNumCtrl = slider; + + auto label = Label::createWithTTF("Blur Sample Num", "fonts/arial.ttf", 12.0f); + addChild(label); + label->setPosition(Vec2(screenSize.width * 3 / 4.0f, screenSize.height / 3.0f - 24.0f)); + } } @@ -575,9 +563,7 @@ bool ShaderBlur::init() if( ShaderTestDemo::init() ) { _blurSprite = SpriteBlur::create("Images/grossini.png"); - auto sprite = Sprite::create("Images/grossini.png"); - auto s = Director::getInstance()->getWinSize(); _blurSprite->setPosition(Vec2(s.width/3, s.height/2)); sprite->setPosition(Vec2(2*s.width/3, s.height/2)); @@ -585,19 +571,24 @@ bool ShaderBlur::init() addChild(_blurSprite); addChild(sprite); - _sliderCtl = createSliderCtl(); + createSliderCtls(); - addChild(_sliderCtl); return true; } return false; } -void ShaderBlur::sliderAction(Ref* sender, Control::EventType controlEvent) +void ShaderBlur::onRadiusChanged(Ref* sender, Control::EventType) { ControlSlider* slider = (ControlSlider*)sender; - _blurSprite->setBlurSize(slider->getValue()); + _blurSprite->setBlurRadius(slider->getValue()); +} + +void ShaderBlur::onSampleNumChanged(Ref* sender, Control::EventType) +{ + ControlSlider* slider = (ControlSlider*)sender; + _blurSprite->setBlurSampleNum(slider->getValue()); } // ShaderRetroEffect diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index 798466dae1..e3788de8bd 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -92,11 +92,14 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual bool init(); - ControlSlider* createSliderCtl(); - void sliderAction(Ref* sender, Control::EventType controlEvent); + void createSliderCtls(); + void onRadiusChanged(Ref* sender, Control::EventType controlEvent); + void onSampleNumChanged(Ref* sender, Control::EventType controlEvent); + protected: SpriteBlur* _blurSprite; - ControlSlider* _sliderCtl; + ControlSlider* _sliderRadiusCtl; + ControlSlider* _sliderNumCtrl; }; class ShaderRetroEffect : public ShaderTestDemo diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index dfd250e781..5c7fa92f11 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -249,80 +249,42 @@ class EffectBlur : public Effect { public: CREATE_FUNC(EffectBlur); - virtual void setTarget(EffectSprite *sprite) override; - - void setGaussian(float value); - void setCustomUniforms(); - void setBlurSize(float f); + void setBlurRadius(float radius); + void setBlurSampleNum(float num); protected: - bool init(float blurSize=3.0); - - int _blurRadius; - Vec2 _pixelSize; - - int _samplingRadius; - float _scale; - float _cons; - float _weightSum; + bool init(float blurRadius = 10.0f, float sampleNum = 5.0f); + + float _blurRadius; + float _blurSampleNum; }; void EffectBlur::setTarget(EffectSprite *sprite) { - Size s = sprite->getTexture()->getContentSizeInPixels(); - _pixelSize = Vec2(1/s.width, 1/s.height); - _glprogramstate->setUniformVec2("onePixelSize", _pixelSize); + Size size = sprite->getTexture()->getContentSizeInPixels(); + _glprogramstate->setUniformVec2("resolution", size); + _glprogramstate->setUniformFloat("blurRadius", _blurRadius); + _glprogramstate->setUniformFloat("sampleNum", _blurSampleNum); } -bool EffectBlur::init(float blurSize) +bool EffectBlur::init(float blurRadius, float sampleNum) { initGLProgramState("Shaders/example_Blur.fsh"); - auto s = Size(100,100); - - _blurRadius = 0; - _pixelSize = Vec2(1/s.width, 1/s.height); - _samplingRadius = 0; - - setBlurSize(blurSize); - - _glprogramstate->setUniformVec2("onePixelSize", _pixelSize); - _glprogramstate->setUniformVec4("gaussianCoefficient", Vec4(_samplingRadius, _scale, _cons, _weightSum)); + _blurRadius = blurRadius; + _blurSampleNum = sampleNum; + return true; } -void EffectBlur::setBlurSize(float f) +void EffectBlur::setBlurRadius(float radius) { - if(_blurRadius == (int)f) - return; - _blurRadius = (int)f; + _blurRadius = radius; +} - _samplingRadius = _blurRadius; - if (_samplingRadius > 10) - { - _samplingRadius = 10; - } - if (_blurRadius > 0) - { - float sigma = _blurRadius / 2.0f; - _scale = -0.5f / (sigma * sigma); - _cons = -1.0f * _scale / 3.141592f; - _weightSum = -_cons; - - float weight; - int squareX; - for(int dx = 0; dx <= _samplingRadius; ++dx) - { - squareX = dx * dx; - weight = _cons * exp(squareX * _scale); - _weightSum += 2.0 * weight; - for (int dy = 1; dy <= _samplingRadius; ++dy) - { - weight = _cons * exp((squareX + dy * dy) * _scale); - _weightSum += 4.0 * weight; - } - } - } +void EffectBlur::setBlurSampleNum(float num) +{ + _blurSampleNum = num; } // Outline diff --git a/tests/cpp-tests/Resources/Shaders/example_Blur.fsh b/tests/cpp-tests/Resources/Shaders/example_Blur.fsh index 169795bc0e..74eefdf0fe 100644 --- a/tests/cpp-tests/Resources/Shaders/example_Blur.fsh +++ b/tests/cpp-tests/Resources/Shaders/example_Blur.fsh @@ -1,5 +1,3 @@ -// Shader taken from: http://webglsamples.googlecode.com/hg/electricflower/electricflower.html - #ifdef GL_ES precision mediump float; #endif @@ -7,50 +5,42 @@ precision mediump float; varying vec4 v_fragmentColor; varying vec2 v_texCoord; -uniform vec4 gaussianCoefficient; -uniform vec2 onePixelSize; +uniform vec2 resolution; +uniform float blurRadius; +uniform float sampleNum; -void main() { - if(gaussianCoefficient.x > 0.0) { - vec4 sum = vec4(0.0); - vec2 offset; - float weight; - float squareX; - - for(float dx = 0.0; dx <= gaussianCoefficient.x; dx += 1.0) { - squareX = dx * dx; - weight = gaussianCoefficient.z * exp(squareX * gaussianCoefficient.y); - - offset.x = -dx * onePixelSize.x; - offset.y = 0.0; - sum += texture2D(CC_Texture0, v_texCoord + offset) * weight; - - offset.x = dx * onePixelSize.x; - sum += texture2D(CC_Texture0, v_texCoord + offset) * weight; - - for(float dy = 1.0; dy <= gaussianCoefficient.x; dy += 1.0) { - weight = gaussianCoefficient.z * exp((squareX + dy * dy) * gaussianCoefficient.y); - - offset.x = -dx * onePixelSize.x; - offset.y = -dy * onePixelSize.y; - sum += texture2D(CC_Texture0, v_texCoord + offset) * weight; - - offset.y = dy * onePixelSize.y; - sum += texture2D(CC_Texture0, v_texCoord + offset) * weight; - - offset.x = dx * onePixelSize.x; - sum += texture2D(CC_Texture0, v_texCoord + offset) * weight; - - offset.y = -dy * onePixelSize.y; - sum += texture2D(CC_Texture0, v_texCoord + offset) * weight; - } - } - sum -= texture2D(CC_Texture0, v_texCoord) * gaussianCoefficient.z; - sum /= gaussianCoefficient.w; - gl_FragColor = sum * v_fragmentColor; - } - else { - gl_FragColor = texture2D(CC_Texture0, v_texCoord) * v_fragmentColor; - } +vec3 blur(vec2); + +void main(void) +{ + vec3 col = blur(v_texCoord); + gl_FragColor = vec4(col, 1.0) * v_fragmentColor; } +vec3 blur(vec2 p) +{ + if (blurRadius > 0.0 && sampleNum > 1.0) + { + vec3 col = vec3(0); + vec2 unit = 1.0 / resolution.xy; + + float r = blurRadius; + float sampleStep = r / sampleNum; + + float count = 0.0; + + for(float x = -r; x < r; x += sampleStep) + { + for(float y = -r; y < r; y += sampleStep) + { + float weight = (r - abs(x)) * (r - abs(y)); + col += texture2D(CC_Texture0, p + vec2(x * unit.x, y * unit.y)).rgb * weight; + count += weight; + } + } + + return col / count; + } + + return texture2D(CC_Texture0, p).rgb; +} diff --git a/tools/jenkins-scripts/job-comment-trigger.py b/tools/jenkins-scripts/job-comment-trigger.py index 8ba9d710af..b425040948 100644 --- a/tools/jenkins-scripts/job-comment-trigger.py +++ b/tools/jenkins-scripts/job-comment-trigger.py @@ -79,7 +79,7 @@ def main(): print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered' return(0) - data = {"state":"pending", "target_url":target_url} + data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Wait available build machine..."} access_token = os.environ['GITHUB_ACCESS_TOKEN'] Headers = {"Authorization":"token " + access_token} diff --git a/tools/jenkins-scripts/job-trigger.py b/tools/jenkins-scripts/job-trigger.py index 54e566e94c..fbdcf0c3e1 100755 --- a/tools/jenkins-scripts/job-trigger.py +++ b/tools/jenkins-scripts/job-trigger.py @@ -90,7 +90,7 @@ def main(): print 'skip build for pull request #' + str(pr_num) return(0) - data = {"state":"pending", "target_url":target_url} + data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Waiting available build machine..."} access_token = os.environ['GITHUB_ACCESS_TOKEN'] Headers = {"Authorization":"token " + access_token} diff --git a/tools/jenkins-scripts/post-build.py b/tools/jenkins-scripts/post-build.py index 78f7ddf735..fb99727de8 100644 --- a/tools/jenkins-scripts/post-build.py +++ b/tools/jenkins-scripts/post-build.py @@ -18,7 +18,7 @@ statuses_url = payload['statuses_url'] J = Jenkins(os.environ['JENKINS_URL']) target_url = os.environ['BUILD_URL'] build_number = int(os.environ['BUILD_NUMBER']) -data = {"state":"pending", "target_url":target_url} +data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Build finished!"} access_token = os.environ['GITHUB_ACCESS_TOKEN'] Headers = {"Authorization":"token " + access_token} @@ -26,9 +26,10 @@ result = J[os.environ['JOB_NAME']].get_build(build_number).get_status() if(result == STATUS_SUCCESS): data['state'] = "success" + data['description'] = "Build successfully!" else: data['state'] = "failure" - + data['description'] = "Build failed!" http_proxy = '' if(os.environ.has_key('HTTP_PROXY')): http_proxy = os.environ['HTTP_PROXY'] diff --git a/tools/jenkins-scripts/pull-request-builder.py b/tools/jenkins-scripts/pull-request-builder.py index d506bb0df5..eb36154c49 100755 --- a/tools/jenkins-scripts/pull-request-builder.py +++ b/tools/jenkins-scripts/pull-request-builder.py @@ -104,7 +104,7 @@ def main(): set_description(pr_desc, target_url) - data = {"state":"pending", "target_url":target_url} + data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Build started..."} access_token = os.environ['GITHUB_ACCESS_TOKEN'] Headers = {"Authorization":"token " + access_token}